]> Cypherpunks repositories - gostls13.git/commitdiff
go/internal/gccgoimporter: accept missed portions of v2 format
authorRobert Griesemer <gri@golang.org>
Tue, 13 Dec 2016 23:00:59 +0000 (15:00 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 14 Dec 2016 18:47:56 +0000 (18:47 +0000)
Fixes #18301.

Change-Id: I990c105904ab62f2225d671bbc10209ec51b12e2
Reviewed-on: https://go-review.googlesource.com/34371
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/go/internal/gccgoimporter/importer_test.go
src/go/internal/gccgoimporter/parser.go
src/go/internal/gccgoimporter/testdata/time.gox [new file with mode: 0644]
src/go/internal/gccgoimporter/testdata/unicode.gox [new file with mode: 0644]

index 58abbba94ef15edcf2720c8ca43a3ae65a6e1df7..2b454701beb0026c66bf6ee74fa3852aa09b0901 100644 (file)
@@ -96,8 +96,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) {
index 7312cb487921a4ea83ce9f4245fef59930583457..3b97c96d433fb016009fb8734cdeaec1e5b7e6d6 100644 (file)
@@ -711,7 +711,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}
 }
 
@@ -766,6 +769,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) {
@@ -797,7 +809,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/src/go/internal/gccgoimporter/testdata/time.gox b/src/go/internal/gccgoimporter/testdata/time.gox
new file mode 100644 (file)
index 0000000..80c2dbc
Binary files /dev/null and b/src/go/internal/gccgoimporter/testdata/time.gox differ
diff --git a/src/go/internal/gccgoimporter/testdata/unicode.gox b/src/go/internal/gccgoimporter/testdata/unicode.gox
new file mode 100644 (file)
index 0000000..e70e539
Binary files /dev/null and b/src/go/internal/gccgoimporter/testdata/unicode.gox differ