mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: split n.Noescape() into separate uses
n.Noescape() was overloaded for two uses: (1) to indicate a function was annotated with //go:noescape, and (2) to indicate that certain temporary allocations don't outlive the current statement. The first use case is redundant with n.Func.Pragma&Noescape!=0, which is the convention we use for checking other function-level pragmas. The second use case is better served by renaming "Noescape" to "Transient". Passes toolstash-check. Change-Id: I0f09d2d5767513894b7bf49da9cdabd04aa4a05e Reviewed-on: https://go-review.googlesource.com/c/go/+/199822 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
5650a53dac
commit
2197321db1
5 changed files with 9 additions and 10 deletions
|
|
@ -495,7 +495,6 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node {
|
|||
|
||||
pragma := fun.Pragma
|
||||
f.Func.Pragma = fun.Pragma
|
||||
f.SetNoescape(pragma&Noescape != 0)
|
||||
if pragma&Systemstack != 0 && pragma&Nosplit != 0 {
|
||||
yyerrorl(f.Pos, "go:nosplit and go:systemstack cannot be combined")
|
||||
}
|
||||
|
|
@ -507,7 +506,7 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node {
|
|||
p.funcBody(f, fun.Body)
|
||||
|
||||
if fun.Body != nil {
|
||||
if f.Noescape() {
|
||||
if f.Func.Pragma&Noescape != 0 {
|
||||
yyerrorl(f.Pos, "can only use //go:noescape with external func implementations")
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue