diff --git a/go/internal/gccgoimporter/importer_test.go b/go/internal/gccgoimporter/importer_test.go index ff09081e..2749409c 100644 --- a/go/internal/gccgoimporter/importer_test.go +++ b/go/internal/gccgoimporter/importer_test.go @@ -97,8 +97,11 @@ var importerTests = [...]importerTest{ {pkgpath: "complexnums", name: "PN", want: "const PN untyped complex", wantval: "(1 + -1i)"}, {pkgpath: "complexnums", name: "PP", want: "const PP untyped complex", wantval: "(1 + 1i)"}, {pkgpath: "conversions", name: "Bits", want: "const Bits Units", wantval: `"bits"`}, - // TODO: enable this entry once bug has been tracked down - //{pkgpath: "imports", wantinits: []string{"imports..import", "fmt..import", "math..import"}}, + {pkgpath: "time", name: "Duration", want: "type Duration int64"}, + {pkgpath: "time", name: "Nanosecond", want: "const Nanosecond Duration", wantval: "1"}, + {pkgpath: "unicode", name: "IsUpper", want: "func IsUpper(r rune) bool"}, + {pkgpath: "unicode", name: "MaxRune", want: "const MaxRune untyped rune", wantval: "1114111"}, + {pkgpath: "imports", wantinits: []string{"imports..import", "fmt..import", "math..import"}}, } func TestGoxImporter(t *testing.T) { diff --git a/go/internal/gccgoimporter/parser.go b/go/internal/gccgoimporter/parser.go index 62853321..ef59b298 100644 --- a/go/internal/gccgoimporter/parser.go +++ b/go/internal/gccgoimporter/parser.go @@ -713,7 +713,10 @@ func (p *parser) parseType(pkg *types.Package) (t types.Type) { func (p *parser) parsePackageInit() PackageInit { name := p.parseUnquotedString() initfunc := p.parseUnquotedString() - priority := int(p.parseInt()) + priority := -1 + if p.version == "v1" { + priority = int(p.parseInt()) + } return PackageInit{Name: name, InitFunc: initfunc, Priority: priority} } @@ -768,6 +771,15 @@ func (p *parser) parseInitDataDirective() { } p.expect(';') + case "init_graph": + p.next() + // The graph data is thrown away for now. + for p.tok != ';' && p.tok != scanner.EOF { + p.parseInt() + p.parseInt() + } + p.expect(';') + case "checksum": // Don't let the scanner try to parse the checksum as a number. defer func(mode uint) { @@ -799,7 +811,7 @@ func (p *parser) parseDirective() { } switch p.lit { - case "v1", "v2", "priority", "init", "checksum": + case "v1", "v2", "priority", "init", "init_graph", "checksum": p.parseInitDataDirective() case "package": diff --git a/go/internal/gccgoimporter/testdata/time.gox b/go/internal/gccgoimporter/testdata/time.gox new file mode 100644 index 00000000..80c2dbcb Binary files /dev/null and b/go/internal/gccgoimporter/testdata/time.gox differ diff --git a/go/internal/gccgoimporter/testdata/unicode.gox b/go/internal/gccgoimporter/testdata/unicode.gox new file mode 100644 index 00000000..e70e5396 Binary files /dev/null and b/go/internal/gccgoimporter/testdata/unicode.gox differ