mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: use explicit type for arg with bad pointer typedef
Fixes #30646 Change-Id: I5b7e986b0588e87b9781cce01445e3c55c06b6fc Reviewed-on: https://go-review.googlesource.com/c/go/+/165897 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
9dc3b8b722
commit
a6436a5655
2 changed files with 6 additions and 1 deletions
|
|
@ -901,7 +901,7 @@ func (p *Package) rewriteCall(f *File, call *Call) (string, bool) {
|
||||||
// constants to the parameter type, to avoid a type mismatch.
|
// constants to the parameter type, to avoid a type mismatch.
|
||||||
ptype := p.rewriteUnsafe(param.Go)
|
ptype := p.rewriteUnsafe(param.Go)
|
||||||
|
|
||||||
if !p.needsPointerCheck(f, param.Go, args[i]) {
|
if !p.needsPointerCheck(f, param.Go, args[i]) || param.BadPointer {
|
||||||
if ptype != param.Go {
|
if ptype != param.Go {
|
||||||
needsUnsafe = true
|
needsUnsafe = true
|
||||||
}
|
}
|
||||||
|
|
@ -2465,13 +2465,16 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
|
||||||
// Treat this typedef as a uintptr.
|
// Treat this typedef as a uintptr.
|
||||||
s := *sub
|
s := *sub
|
||||||
s.Go = c.uintptr
|
s.Go = c.uintptr
|
||||||
|
s.BadPointer = true
|
||||||
sub = &s
|
sub = &s
|
||||||
// Make sure we update any previously computed type.
|
// Make sure we update any previously computed type.
|
||||||
if oldType := typedef[name.Name]; oldType != nil {
|
if oldType := typedef[name.Name]; oldType != nil {
|
||||||
oldType.Go = sub.Go
|
oldType.Go = sub.Go
|
||||||
|
oldType.BadPointer = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.Go = name
|
t.Go = name
|
||||||
|
t.BadPointer = sub.BadPointer
|
||||||
if unionWithPointer[sub.Go] {
|
if unionWithPointer[sub.Go] {
|
||||||
unionWithPointer[t.Go] = true
|
unionWithPointer[t.Go] = true
|
||||||
}
|
}
|
||||||
|
|
@ -2481,6 +2484,7 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
|
||||||
if oldType == nil {
|
if oldType == nil {
|
||||||
tt := *t
|
tt := *t
|
||||||
tt.Go = sub.Go
|
tt.Go = sub.Go
|
||||||
|
tt.BadPointer = sub.BadPointer
|
||||||
typedef[name.Name] = &tt
|
typedef[name.Name] = &tt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ type Type struct {
|
||||||
Go ast.Expr
|
Go ast.Expr
|
||||||
EnumValues map[string]int64
|
EnumValues map[string]int64
|
||||||
Typedef string
|
Typedef string
|
||||||
|
BadPointer bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// A FuncType collects information about a function type in both the C and Go worlds.
|
// A FuncType collects information about a function type in both the C and Go worlds.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue