]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add support for //go:nointerface for -G=3
authorMatthew Dempsky <mdempsky@google.com>
Wed, 18 Aug 2021 21:36:45 +0000 (14:36 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 19 Aug 2021 00:26:22 +0000 (00:26 +0000)
This is used within Google's internal code repo, so getting it working
is a pre-req for enabling -G=3 by default.

Change-Id: Icbc570948c852ca09cdb2a59f778140f620244b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/343429
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/noder/decl.go
test/run.go

index 429c8a14c8ad1f1b436ac25742e671ab215b46f3..cec31d87b754cdfd065cfb79b158cc66b06bc918 100644 (file)
@@ -97,6 +97,17 @@ func (g *irgen) funcDecl(out *ir.Nodes, decl *syntax.FuncDecl) {
        if fn.Pragma&ir.Systemstack != 0 && fn.Pragma&ir.Nosplit != 0 {
                base.ErrorfAt(fn.Pos(), "go:nosplit and go:systemstack cannot be combined")
        }
+       if fn.Pragma&ir.Nointerface != 0 {
+               // Propagate //go:nointerface from Func.Pragma to Field.Nointerface.
+               // This is a bit roundabout, but this is the earliest point where we've
+               // processed the function's pragma flags, and we've also already created
+               // the Fields to represent the receiver's method set.
+               if recv := fn.Type().Recv(); recv != nil {
+                       typ := types.ReceiverBaseType(recv.Type)
+                       meth := typecheck.Lookdot1(fn, typecheck.Lookup(decl.Name.Value), typ, typ.Methods(), 0)
+                       meth.SetNointerface(true)
+               }
+       }
 
        if decl.Name.Value == "init" && decl.Recv == nil {
                g.target.Inits = append(g.target.Inits, fn)
index 5d5adc3623c0334c8fe00119e0963d61759209e2..f5971d2d151323414167c977701e5e0571f1929f 100644 (file)
@@ -2180,8 +2180,6 @@ var types2Failures32Bit = setOf(
 var g3Failures = setOf(
        "writebarrier.go", // correct diagnostics, but different lines (probably irgen's fault)
 
-       "fixedbugs/issue30862.go", // -G=3 doesn't handle //go:nointerface
-
        "typeparam/nested.go", // -G=3 doesn't support function-local types with generics
 
        "typeparam/mdempsky/4.go",  // -G=3 can't export functions with labeled breaks in loops