Commit a5cd53a9 authored by Alan Donovan's avatar Alan Donovan

cmd/compile/internal/gc: support invalid types/constants in binary export data

(Corresponding x/tools/go/gcimporter change is https://go-review.googlesource.com/#/c/20827/)

Change-Id: I64e7fee2e273d387f1c51b87986294489978d250
Reviewed-on: https://go-review.googlesource.com/20828Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent 2d4c3d24
......@@ -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],
}
......
......@@ -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)
......
......@@ -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],
}
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