mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
5951823853
commit
0417872809
2 changed files with 10 additions and 0 deletions
|
|
@ -14,6 +14,11 @@ void scatter() {
|
||||||
printf("scatter = %p\n", p);
|
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
|
// this example is in issue 3253
|
||||||
int hola = 0;
|
int hola = 0;
|
||||||
int testHola() { return hola; }
|
int testHola() { return hola; }
|
||||||
|
|
|
||||||
|
|
@ -491,6 +491,11 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
|
||||||
name, _ := e.Val(dwarf.AttrName).(string)
|
name, _ := e.Val(dwarf.AttrName).(string)
|
||||||
typOff, _ := e.Val(dwarf.AttrType).(dwarf.Offset)
|
typOff, _ := e.Val(dwarf.AttrType).(dwarf.Offset)
|
||||||
if name == "" || typOff == 0 {
|
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")
|
fatalf("malformed DWARF TagVariable entry")
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(name, "__cgo__") {
|
if !strings.HasPrefix(name, "__cgo__") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue