]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.5] cmd/cgo: ignore vars with no name or type if they have a AttrS...
authorIan Lance Taylor <iant@golang.org>
Fri, 20 Nov 2015 21:53:18 +0000 (13:53 -0800)
committerRuss Cox <rsc@golang.org>
Mon, 23 Nov 2015 04:38:50 +0000 (04:38 +0000)
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>
misc/cgo/test/issue1635.go
src/cmd/cgo/gcc.go

index 6bfe110fdf40bb0001a045c8f8c1f76a33472135..cc4be9093d1a07e0fecd4935ff2d1966e1775a55 100644 (file)
@@ -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; }
index b64849a8d16f37f577cad456b40b8822f4371b6c..e0b89ec14cb78232a39a673be3d3b5a6f5fb0e27 100644 (file)
@@ -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__") {