]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: allow objStub from unsafe package
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 1 Sep 2021 12:58:31 +0000 (19:58 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 2 Sep 2021 06:43:50 +0000 (06:43 +0000)
CL 346469 added support for unsafe.Sizeof and friends to operate on
generic parameters for compiler importer/exporter. This CL adds support
for unified IR.

Updates #48094

Change-Id: I63af1a7c3478f59b03ecc23229ac2254d3457868
Reviewed-on: https://go-review.googlesource.com/c/go/+/346769
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/noder/reader2.go

index 8f3f0a50e9ced72c272921604236c10fa0cd3303..a775ffda34a95c84acb83d6167e69f68e974d463 100644 (file)
@@ -147,6 +147,10 @@ func (r *reader2) doPkg() *types2.Package {
        if path == "builtin" {
                return nil // universe
        }
+       if path == "unsafe" {
+               // TODO(mdempsky): This should be in r.p.imports.
+               return types2.Unsafe
+       }
        if path == "" {
                path = r.p.pkgPath
        }
@@ -362,7 +366,7 @@ func (pr *pkgReader2) objIdx(idx int) (*types2.Package, string) {
        tag := codeObj(rname.code(syncCodeObj))
 
        if tag == objStub {
-               assert(objPkg == nil)
+               assert(objPkg == nil || objPkg == types2.Unsafe)
                return objPkg, objName
        }