aboutsummaryrefslogtreecommitdiff
path: root/misc/cgo/errors
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2013-09-03 21:15:15 -0700
committerIan Lance Taylor <iant@golang.org>2013-09-03 21:15:15 -0700
commitf68c23e2bba617d8f9bbe1cb53a920aeaf8901ad (patch)
tree0f91d00295700581344c67109e79c795cee6be3c /misc/cgo/errors
parent0ba7ffe2897cd9771de172362e9edcb5f733cf1f (diff)
downloadgo-f68c23e2bba617d8f9bbe1cb53a920aeaf8901ad.tar.xz
cmd/cgo: don't let #cgo directives mess up line numbering
Fixes #5272. R=golang-dev, r CC=golang-dev https://golang.org/cl/13498046
Diffstat (limited to 'misc/cgo/errors')
-rw-r--r--misc/cgo/errors/err1.go14
-rwxr-xr-xmisc/cgo/errors/test.bash19
2 files changed, 33 insertions, 0 deletions
diff --git a/misc/cgo/errors/err1.go b/misc/cgo/errors/err1.go
new file mode 100644
index 0000000000..78094c6b51
--- /dev/null
+++ b/misc/cgo/errors/err1.go
@@ -0,0 +1,14 @@
+package main
+
+/*
+#cgo LDFLAGS: -c
+
+void test() {
+ xxx; // This is line 7.
+}
+*/
+import "C"
+
+func main() {
+ C.test()
+}
diff --git a/misc/cgo/errors/test.bash b/misc/cgo/errors/test.bash
new file mode 100755
index 0000000000..e9fa6d0195
--- /dev/null
+++ b/misc/cgo/errors/test.bash
@@ -0,0 +1,19 @@
+# Copyright 2013 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+if go tool cgo err1.go >errs 2>&1; then
+ echo 1>&2 misc/cgo/errors/test.bash: BUG: expected cgo to fail but it succeeded
+ exit 1
+fi
+if ! test -s errs; then
+ echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error output but saw none
+ exit 1
+fi
+if ! fgrep err1.go:7 errs >/dev/null 2>&1; then
+ echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error on line 7 but saw:
+ cat 1>&2 errs
+ exit 1
+fi
+rm -rf errs _obj
+exit 0