1
0
mirror of https://github.com/golang/go synced 2024-11-20 08:04:42 -07:00
go/src
Russ Cox b2290229c2 cmd/cgo: add #line directives to avoid printing bogus references to Go source files
A bit contrived to come up with an example, but it happened in #15836, somehow.

	$ cat /tmp/x.go
	package main

	/*
	#include <stddef.h>

	int foo(void);

	int foo(void) {
		return 2;
	}

	#define int asdf
	*/
	import "C"

	func main() {
		println(C.foo())
	}

	$ go run /tmp/x.go
	# command-line-arguments
	cgo-builtin-prolog:9:31: error: unknown type name 'asdf'   <<<<<
	_GoString_ GoStringN(char *p, int l);
	                              ^
	/tmp/x.go:12:13: note: expanded from macro 'int'
	#define int asdf
	            ^
	cgo-builtin-prolog:10:28: error: unknown type name 'asdf'  <<<<<
	_GoBytes_ GoBytes(void *p, int n);
	                           ^
	/tmp/x.go:12:13: note: expanded from macro 'int'
	#define int asdf
	            ^
	2 errors generated.

The two marked lines used to refer incorrectly to /tmp/x.go.

Fixes #15836.

Change-Id: I08ef60a53cfd148112fceb651eaf7b75d94a7a8d
Reviewed-on: https://go-review.googlesource.com/32613
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 16:35:25 +00:00
..
archive archive/tar: disable prefix field in Writer 2016-11-02 20:18:38 +00:00
bufio bufio: remove unnecessary "continue" 2016-10-24 14:49:44 +00:00
builtin
bytes bytes, strings: update s390x code to match amd64 changes 2016-11-02 15:56:24 +00:00
cmd cmd/cgo: add #line directives to avoid printing bogus references to Go source files 2016-11-03 16:35:25 +00:00
compress compress/flate: tighten the BestSpeed max match offset bound. 2016-10-30 22:52:14 +00:00
container
context context: add comments to the WithCancel example, apply minor improvements 2016-10-26 22:35:07 +00:00
crypto all: update s390x assembly to use vet-friendly names 2016-11-03 15:04:44 +00:00
database/sql database/sql: correctly spell constants 2016-10-31 17:17:46 +00:00
debug
encoding encoding/asn1: document that default:x tag only has meaning with optional tag 2016-11-03 16:04:55 +00:00
errors
expvar
flag flag: arrange for FlagSet.Usage to be non-nil by default 2016-10-26 16:13:40 +00:00
fmt fmt: document that unexported struct fields don't get the String/Error treatment 2016-10-26 13:56:45 +00:00
go go/types: set up correct type with NewAlias 2016-11-02 23:31:37 +00:00
hash
html html/template, text/template: drop defined template list from errors 2016-10-28 17:10:55 +00:00
image image/png: implement grayscale transparency. 2016-10-28 02:10:13 +00:00
index/suffixarray
internal internal/pprof/profile: new package, moved from cmd/internal/pprof/profile 2016-11-02 19:09:11 +00:00
io
log all: freeze net/rpc and reword the 'frozen' message in other frozen packages 2016-10-26 16:11:07 +00:00
math math/big: flip long/short flag on TestFloat32Distribution 2016-10-27 21:44:37 +00:00
mime mime/multipart: simplify Part.Read 2016-10-28 19:05:47 +00:00
net net: disallow dialing and listening on port > 65535 on Plan 9 2016-11-03 13:58:02 +00:00
os os: adjust (*File).Read comment 2016-10-28 19:19:11 +00:00
path path/filepath: fix Abs on Windows 2016-10-29 16:44:45 +00:00
plugin plugin: do not leak cRelName on error path 2016-11-01 16:04:28 +00:00
reflect reflect: clarify that NumMethod returns only the number of exported methods 2016-10-31 17:17:05 +00:00
regexp
runtime runtime/testdata/testprog: increase GCFairness2 timeout to 1s 2016-11-03 15:48:57 +00:00
sort
strconv
strings bytes, strings: update s390x code to match amd64 changes 2016-11-02 15:56:24 +00:00
sync all: update s390x assembly to use vet-friendly names 2016-11-03 15:04:44 +00:00
syscall syscall: remove X__cmsg_data from Cmsghdr 2016-10-30 19:04:09 +00:00
testing testing: introduce testing/internal/testdeps for holding testmain dependencies 2016-11-02 19:14:39 +00:00
text html/template, text/template: drop defined template list from errors 2016-10-28 17:10:55 +00:00
time time: document that only Jan and January, Mon and Monday are recognized 2016-11-03 16:04:14 +00:00
unicode unicode/utf8: optimize ValidRune 2016-10-26 23:02:52 +00:00
unsafe
vendor/golang_org/x vendor/golang_org/text/unicode/norm: re-vendor 2016-10-31 19:27:05 +00:00
all.bash
all.bat
all.rc
androidtest.bash
bootstrap.bash
buildall.bash
clean.bash
clean.bat
clean.rc
cmp.bash
iostest.bash
make.bash
make.bat
Make.dist
make.rc
naclmake.bash
nacltest.bash
race.bash
race.bat
run.bash
run.bat
run.rc