From: Matthew Dempsky Date: Mon, 12 Sep 2016 20:27:36 +0000 (-0700) Subject: cmd/compile: remove Pointer from builtin/unsafe.go X-Git-Tag: go1.8beta1~1363 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6758eedf898c48d6ca4abd42f44622abf7c005c2;p=gostls13.git cmd/compile: remove Pointer from builtin/unsafe.go We already explicitly construct the "unsafe.Pointer" type in typeinit because we need it for Types[TUNSAFEPTR]. No point in also having it in builtin/unsafe.go if it just means (*importer).importtype needs to fix it. Change-Id: Ife8a5a73cbbe2bfcabe8b25ee4f7e0f5fd0570b4 Reviewed-on: https://go-review.googlesource.com/29082 Run-TryBot: Matthew Dempsky Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/compile/internal/gc/bimport.go b/src/cmd/compile/internal/gc/bimport.go index 37ce784e7a..713a7f4610 100644 --- a/src/cmd/compile/internal/gc/bimport.go +++ b/src/cmd/compile/internal/gc/bimport.go @@ -390,13 +390,6 @@ func (p *importer) newtyp(etype EType) *Type { // importtype declares that pt, an imported named type, has underlying type t. func (p *importer) importtype(pt, t *Type) { - // override declaration in unsafe.go for Pointer. - // there is no way in Go code to define unsafe.Pointer - // so we have to supply it. - if incannedimport != 0 && importpkg.Name == "unsafe" && pt.Nod.Sym.Name == "Pointer" { - t = Types[TUNSAFEPTR] - } - if pt.Etype == TFORW { n := pt.Nod copytype(pt.Nod, t) diff --git a/src/cmd/compile/internal/gc/builtin.go b/src/cmd/compile/internal/gc/builtin.go index a52bb053e1..9df4cc2a12 100644 --- a/src/cmd/compile/internal/gc/builtin.go +++ b/src/cmd/compile/internal/gc/builtin.go @@ -106,6 +106,5 @@ const runtimeimport = "" + "\x11msanwrite\x00\x04\x16\x96\x03\x00`\x16\x98\x03\x00`\x00\v\xf8\x01\v\x00\x01\x00\n$$\n" const unsafeimport = "" + - "version 2\n\n\x00\x00\x01\vunsafe\x00\x05\r\rPointer\x00\x16\x00\t\x0fOff" + - "setof\x00\x01:\x00\x01\x16\x00\t\vSizeof\x00\x01:\x00\x01\x16\x00\t\rAlignof\x00\x01:\x00" + - "\x01\x16\x00\v\b\v\x00\x01\x00\n$$\n" + "version 2\n\n\x00\x00\x01\vunsafe\x00\t\x0fOffsetof\x00\x01:\x00\x01\x16\x00\t" + + "\vSizeof\x00\x01:\x00\x01\x16\x00\t\rAlignof\x00\x01:\x00\x01\x16\x00\v\x06\v\x00\x01\x00\n$$\n" diff --git a/src/cmd/compile/internal/gc/builtin/unsafe.go b/src/cmd/compile/internal/gc/builtin/unsafe.go index 6e25db65cc..2417e7e158 100644 --- a/src/cmd/compile/internal/gc/builtin/unsafe.go +++ b/src/cmd/compile/internal/gc/builtin/unsafe.go @@ -10,7 +10,7 @@ package unsafe -type Pointer uintptr // not really; filled in by compiler +// Type Pointer is constructed directly in typeinit. // return types here are ignored; see unsafe.go func Offsetof(any) uintptr diff --git a/src/cmd/compile/internal/gc/universe.go b/src/cmd/compile/internal/gc/universe.go index 1e5650ffc2..9ca205ce6a 100644 --- a/src/cmd/compile/internal/gc/universe.go +++ b/src/cmd/compile/internal/gc/universe.go @@ -163,7 +163,6 @@ func typeinit() { t.Sym = Pkglookup("Pointer", unsafepkg) t.Sym.Def = typenod(t) t.Sym.Def.Name = new(Name) - dowidth(Types[TUNSAFEPTR]) Tptr = TPTR32