From c85695a117f1ec3b800ba14570876cfcd2075c1f Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Wed, 18 Aug 2021 14:36:45 -0700 Subject: cmd/compile: add support for //go:nointerface for -G=3 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 Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/cmd/compile/internal/noder/decl.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/cmd/compile/internal/noder/decl.go') diff --git a/src/cmd/compile/internal/noder/decl.go b/src/cmd/compile/internal/noder/decl.go index 429c8a14c8..cec31d87b7 100644 --- a/src/cmd/compile/internal/noder/decl.go +++ b/src/cmd/compile/internal/noder/decl.go @@ -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) -- cgit v1.2.3-54-g00ecf