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 <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
// 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)
"\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"
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
t.Sym = Pkglookup("Pointer", unsafepkg)
t.Sym.Def = typenod(t)
t.Sym.Def.Name = new(Name)
-
dowidth(Types[TUNSAFEPTR])
Tptr = TPTR32