Commit 6697aa58 authored by Robert Griesemer's avatar Robert Griesemer

go/internal/gccgoimporter: parse optional escape info in export data

Fixes #23324.

Change-Id: Ie2383bad35f0bcc1344a8a1683be08d5fd0eea96
Reviewed-on: https://go-review.googlesource.com/86977Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
parent 5e1dcb7a
......@@ -102,6 +102,7 @@ var importerTests = [...]importerTest{
{pkgpath: "unicode", name: "MaxRune", want: "const MaxRune untyped rune", wantval: "1114111"},
{pkgpath: "imports", wantinits: []string{"imports..import", "fmt..import", "math..import"}},
{pkgpath: "alias", name: "IntAlias2", want: "type IntAlias2 = Int"},
{pkgpath: "escapeinfo", name: "NewT", want: "func NewT(data []byte) *T"},
}
func TestGoxImporter(t *testing.T) {
......
......@@ -226,6 +226,14 @@ func (p *parser) parseField(pkg *types.Package) (field *types.Var, tag string) {
// Param = Name ["..."] Type .
func (p *parser) parseParam(pkg *types.Package) (param *types.Var, isVariadic bool) {
name := p.parseName()
if p.tok == '<' && p.scanner.Peek() == 'e' {
// EscInfo = "<esc:" int ">" . (optional and ignored)
p.next()
p.expectKeyword("esc")
p.expect(':')
p.expect(scanner.Int)
p.expect('>')
}
if p.tok == '.' {
p.next()
p.expect('.')
......
// Test case for escape info in export data. To compile and extract .gox file:
// gccgo -fgo-optimize-allocs -c escapeinfo.go
// objcopy -j .go_export escapeinfo.o escapeinfo.gox
package escapeinfo
type T struct{ data []byte }
func NewT(data []byte) *T {
return &T{data}
}
func (*T) Read(p []byte) {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment