Skip to content

Commit

Permalink
cmd/cgo: ignore vars with no name or type if they have a AttrSpecific…
Browse files Browse the repository at this point in the history
…ation

Fixes golang#13344.

Change-Id: I33c6721fd33d144c85c87840ddf27ce15aa72328
Reviewed-on: https://go-review.googlesource.com/17151
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Minux Ma <[email protected]>
  • Loading branch information
ianlancetaylor authored and rsc committed Nov 23, 2015
1 parent 5951823 commit 0417872
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions misc/cgo/test/issue1635.go
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
5 changes: 5 additions & 0 deletions src/cmd/cgo/gcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,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__") {
Expand Down

0 comments on commit 0417872

Please sign in to comment.