aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2015-11-20 13:53:18 -0800
committerRuss Cox <rsc@golang.org>2015-11-23 04:38:50 +0000
commitbebbc624029d13a7c81957d971a2dce9d3bad1fb (patch)
treefb92e3a9e34236bf545908ce6f418f58e9496763
parent2876020ee7dc9bb927a8968c2cfd6017b85834a2 (diff)
downloadgo-bebbc624029d13a7c81957d971a2dce9d3bad1fb.tar.gz
go-bebbc624029d13a7c81957d971a2dce9d3bad1fb.zip
[release-branch.go1.5] cmd/cgo: ignore vars with no name or type if they have a AttrSpecification
Fixes #13344. Change-Id: I33c6721fd33d144c85c87840ddf27ce15aa72328 Reviewed-on: https://go-review.googlesource.com/17151 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Minux Ma <minux@golang.org> Reviewed-on: https://go-review.googlesource.com/17145 Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r--misc/cgo/test/issue1635.go5
-rw-r--r--src/cmd/cgo/gcc.go5
2 files changed, 10 insertions, 0 deletions
diff --git a/misc/cgo/test/issue1635.go b/misc/cgo/test/issue1635.go
index 6bfe110fdf..cc4be9093d 100644
--- a/misc/cgo/test/issue1635.go
+++ b/misc/cgo/test/issue1635.go
@@ -14,6 +14,11 @@ void scatter() {
printf("scatter = %p\n", p);
}
+// Adding this explicit extern declaration makes this a test for
+// https://gcc.gnu.org/PR68072 aka https://golang.org/issue/13344 .
+// It used to cause a cgo error when building with GCC 6.
+extern int hola;
+
// this example is in issue 3253
int hola = 0;
int testHola() { return hola; }
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go
index b64849a8d1..e0b89ec14c 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -490,6 +490,11 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
name, _ := e.Val(dwarf.AttrName).(string)
typOff, _ := e.Val(dwarf.AttrType).(dwarf.Offset)
if name == "" || typOff == 0 {
+ if e.Val(dwarf.AttrSpecification) != nil {
+ // Since we are reading all the DWARF,
+ // assume we will see the variable elsewhere.
+ break
+ }
fatalf("malformed DWARF TagVariable entry")
}
if !strings.HasPrefix(name, "__cgo__") {