mirror of https://github.com/golang/go.git
go/internal/gccgoimporter: support notinheap annotation
Port https://golang.org/cl/265702 from the main Go repo. Original CL description: The gofrontend has started emitting a notinheap annotation for types marked go:notinheap. For golang/go#41761 Change-Id: Ic14ffda4b0c3eef850ad85dbf9af755283a5196b Reviewed-on: https://go-review.googlesource.com/c/tools/+/265718 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
8dabb74018
commit
6312208388
|
|
@ -100,6 +100,7 @@ var importerTests = [...]importerTest{
|
|||
{pkgpath: "issue30628", name: "Apple", want: "type Apple struct{hey sync.RWMutex; x int; RQ [517]struct{Count uintptr; NumBytes uintptr; Last uintptr}}"},
|
||||
{pkgpath: "issue31540", name: "S", gccgoVersion: 7, want: "type S struct{b int; map[Y]Z}"},
|
||||
{pkgpath: "issue34182", name: "T1", want: "type T1 struct{f *T2}"},
|
||||
{pkgpath: "notinheap", name: "S", want: "type S struct{}"},
|
||||
}
|
||||
|
||||
func TestGoxImporter(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -521,6 +521,13 @@ func (p *parser) parseNamedType(nlist []interface{}) types.Type {
|
|||
p.errorf("%v has nil type", obj)
|
||||
}
|
||||
|
||||
if p.tok == scanner.Ident && p.lit == "notinheap" {
|
||||
p.next()
|
||||
// The go/types package has no way of recording that
|
||||
// this type is marked notinheap. Presumably no user
|
||||
// of this package actually cares.
|
||||
}
|
||||
|
||||
// type alias
|
||||
if p.tok == '=' {
|
||||
p.next()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
package notinheap
|
||||
|
||||
//go:notinheap
|
||||
type S struct{}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
v3;
|
||||
package notinheap
|
||||
pkgpath notinheap
|
||||
init notinheap ~notinheap
|
||||
types 3 2 30 18
|
||||
type 1 "S" notinheap <type 2>
|
||||
type 2 struct { }
|
||||
Loading…
Reference in New Issue