1
0
mirror of https://github.com/golang/go synced 2024-09-28 22:14:28 -06:00

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 <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Josh Bleecher Snyder 2017-03-14 09:29:23 -07:00
parent 0d87f6a62e
commit 5f5d882f5c
2 changed files with 3 additions and 3 deletions

View File

@ -321,6 +321,9 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node {
if f.Noescape() && len(body) != 0 {
yyerror("can only use //go:noescape with external func implementations")
}
if pragma&Systemstack != 0 && pragma&Nosplit != 0 {
yyerror("go:nosplit and go:systemstack cannot be combined")
}
f.Func.Pragma = pragma
lineno = makePos(fun.Pos().Base(), fun.EndLine, 0)
f.Func.Endlineno = lineno

View File

@ -393,9 +393,6 @@ func compile(fn *Node) {
}
if fn.Func.Pragma&Systemstack != 0 {
ptxt.From.Sym.Set(obj.AttrCFunc, true)
if fn.Func.Pragma&Nosplit != 0 {
yyerror("go:nosplit and go:systemstack cannot be combined")
}
}
// Clumsy but important.