mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: make C function pointers non-assignable
Fixes #7757. Fixes #8488. LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/118690044
This commit is contained in:
parent
e4d4787581
commit
11016f62d8
4 changed files with 23 additions and 2 deletions
|
|
@ -650,7 +650,13 @@ func (p *Package) rewriteRef(f *File) {
|
|||
f.Name[fpName] = name
|
||||
}
|
||||
r.Name = name
|
||||
expr = ast.NewIdent(name.Mangle)
|
||||
// Rewrite into call to _Cgo_ptr to prevent assignments. The _Cgo_ptr
|
||||
// function is defined in out.go and simply returns its argument. See
|
||||
// issue 7757.
|
||||
expr = &ast.CallExpr{
|
||||
Fun: &ast.Ident{NamePos: (*r.Expr).Pos(), Name: "_Cgo_ptr"},
|
||||
Args: []ast.Expr{ast.NewIdent(name.Mangle)},
|
||||
}
|
||||
} else if r.Name.Kind == "type" {
|
||||
// Okay - might be new(T)
|
||||
expr = r.Name.Type.Go
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue