Skip to content

Commit 5f5d882

Browse files
committed
cmd/compile: catch bad pragma combination earlier
Bad pragmas should never make it to the backend. I've confirmed manually that the error position is unchanged. Updates #15756 Updates #19250 Change-Id: If14f7ce868334f809e337edc270a49680b26f48e Reviewed-on: https://go-review.googlesource.com/38152 Run-TryBot: Josh Bleecher Snyder <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 0d87f6a commit 5f5d882

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/cmd/compile/internal/gc/noder.go

+3
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node {
321321
if f.Noescape() && len(body) != 0 {
322322
yyerror("can only use //go:noescape with external func implementations")
323323
}
324+
if pragma&Systemstack != 0 && pragma&Nosplit != 0 {
325+
yyerror("go:nosplit and go:systemstack cannot be combined")
326+
}
324327
f.Func.Pragma = pragma
325328
lineno = makePos(fun.Pos().Base(), fun.EndLine, 0)
326329
f.Func.Endlineno = lineno

src/cmd/compile/internal/gc/pgen.go

-3
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,6 @@ func compile(fn *Node) {
393393
}
394394
if fn.Func.Pragma&Systemstack != 0 {
395395
ptxt.From.Sym.Set(obj.AttrCFunc, true)
396-
if fn.Func.Pragma&Nosplit != 0 {
397-
yyerror("go:nosplit and go:systemstack cannot be combined")
398-
}
399396
}
400397

401398
// Clumsy but important.

0 commit comments

Comments
 (0)