]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/gc: support invalid types/constants in binary export data
authorAlan Donovan <adonovan@google.com>
Fri, 18 Mar 2016 15:13:24 +0000 (11:13 -0400)
committerAlan Donovan <adonovan@google.com>
Fri, 18 Mar 2016 16:33:38 +0000 (16:33 +0000)
(Corresponding x/tools/go/gcimporter change is https://go-review.googlesource.com/#/c/20827/)

Change-Id: I64e7fee2e273d387f1c51b87986294489978d250
Reviewed-on: https://go-review.googlesource.com/20828
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/bimport.go
src/go/internal/gcimporter/bimport.go

index 7e5dbb0dd09e739b067802266b8053172a8f413e..cbe2a812a4abea62e6b4dc5a86c36e95e6d45884 100644 (file)
@@ -1190,6 +1190,7 @@ const (
        complexTag
        stringTag
        nilTag
+       unknownTag // not used by gc (only appears in packages with errors)
 )
 
 // Debugging support.
@@ -1218,6 +1219,8 @@ var tagString = [...]string{
        -fractionTag: "fraction",
        -complexTag:  "complex",
        -stringTag:   "string",
+       -nilTag:      "nil",
+       -unknownTag:  "unknown",
 }
 
 // untype returns the "pseudo" untyped type for a Ctype (import/export use only).
@@ -1289,6 +1292,9 @@ func predeclared() []*Type {
                        // package unsafe
                        Types[TUNSAFEPTR],
 
+                       // invalid type (package contains errors)
+                       Types[Txxx],
+
                        // any type, for builtin export data
                        Types[TANY],
                }
index 377d97293244a743f4bd3eafaaa829ff13abc2fb..f063557363574334b40440374b1785e57b4c8772 100644 (file)
@@ -509,6 +509,9 @@ func (p *importer) value(typ *Type) (x Val) {
        case stringTag:
                x.U = p.string()
 
+       case unknownTag:
+               Fatalf("importer: unknown constant (importing package with errors)")
+
        case nilTag:
                x.U = new(NilVal)
 
index ddace33d0ce1efac6fd3c12fb0a4decfe88ee7b4..c982724418c7562bd357df44540743a8afbe2eee 100644 (file)
@@ -681,7 +681,10 @@ var predeclared = []types.Type{
        // package unsafe
        types.Typ[types.UnsafePointer],
 
-       // any type, for builtin export data
+       // invalid type
+       types.Typ[types.Invalid], // only appears in packages with errors
+
        // TODO(mdempsky): Provide an actual Type value to represent "any"?
+       // (Why exactly does gc emit the "any" type?)
        types.Typ[types.Invalid],
 }