diff options
| author | David Crawshaw <crawshaw@golang.org> | 2016-09-24 08:39:31 +1000 |
|---|---|---|
| committer | David Crawshaw <crawshaw@golang.org> | 2016-11-03 14:07:34 +0000 |
| commit | 8eb9fdaa0123fc98cb70f58801eb74c8a6f92817 (patch) | |
| tree | 51b8d1e7810c3aef0e05da0f62cc1803eb480ff1 /misc/cgo/testplugin/src | |
| parent | 5ac3e7d6a7717bf2f722803e1852ba991af4e724 (diff) | |
| download | go-8eb9fdaa0123fc98cb70f58801eb74c8a6f92817.tar.xz | |
cmd/compile: write type symbols referenced in ptabs
The exported symbol for a plugin can be the only reference to a
type in a program. In particular, "var F func()" will have
the type *func(), which is uncommon.
Fixes #17140
Change-Id: Ide2104edbf087565f5377374057ae54e0c00c57e
Reviewed-on: https://go-review.googlesource.com/29692
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'misc/cgo/testplugin/src')
| -rw-r--r-- | misc/cgo/testplugin/src/host/host.go | 12 | ||||
| -rw-r--r-- | misc/cgo/testplugin/src/sub/plugin1/plugin1.go | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/misc/cgo/testplugin/src/host/host.go b/misc/cgo/testplugin/src/host/host.go index 636655aa5c..477a9e63a2 100644 --- a/misc/cgo/testplugin/src/host/host.go +++ b/misc/cgo/testplugin/src/host/host.go @@ -61,6 +61,15 @@ func main() { log.Fatalf("plugin.Open(%q) failed: %v", subpPath, err) } + funcVar, err := subp.Lookup("FuncVar") + if err != nil { + log.Fatalf(`sub/plugin1.Lookup("FuncVar") failed: %v`, err) + } + called := false + *funcVar.(*func()) = func() { + called = true + } + readFunc, err = subp.Lookup("ReadCommonX") if err != nil { log.Fatalf(`sub/plugin1.Lookup("ReadCommonX") failed: %v`, err) @@ -68,6 +77,9 @@ func main() { if got := readFunc.(func() int)(); got != wantX { log.Fatalf("sub/plugin1.ReadCommonX()=%d, want %d", got, wantX) } + if !called { + log.Fatal("calling ReadCommonX did not call FuncVar") + } subf, err := subp.Lookup("F") if err != nil { diff --git a/misc/cgo/testplugin/src/sub/plugin1/plugin1.go b/misc/cgo/testplugin/src/sub/plugin1/plugin1.go index 4ed76c7caf..cf9000c4a4 100644 --- a/misc/cgo/testplugin/src/sub/plugin1/plugin1.go +++ b/misc/cgo/testplugin/src/sub/plugin1/plugin1.go @@ -11,7 +11,10 @@ import "common" func F() int { return 17 } +var FuncVar = func() {} + func ReadCommonX() int { + FuncVar() return common.X } |
