mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: recognize known C typedefs as types
Fixes #14483. Change-Id: I0cddfe27fd8d00ba85659d0b618410e39ebf45cb Reviewed-on: https://go-review.googlesource.com/19860 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
922ce58de0
commit
71cc445cf9
2 changed files with 17 additions and 4 deletions
|
|
@ -819,14 +819,17 @@ func (p *Package) hasSideEffects(f *File, x ast.Expr) bool {
|
|||
func (p *Package) isType(t ast.Expr) bool {
|
||||
switch t := t.(type) {
|
||||
case *ast.SelectorExpr:
|
||||
if t.Sel.Name != "Pointer" {
|
||||
return false
|
||||
}
|
||||
id, ok := t.X.(*ast.Ident)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return id.Name == "unsafe"
|
||||
if id.Name == "unsafe" && t.Sel.Name == "Pointer" {
|
||||
return true
|
||||
}
|
||||
if id.Name == "C" && typedef["_Ctype_"+t.Sel.Name] != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
case *ast.Ident:
|
||||
// TODO: This ignores shadowing.
|
||||
switch t.Name {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue