From: Josh Bleecher Snyder Date: Tue, 14 Mar 2017 16:29:23 +0000 (-0700) Subject: cmd/compile: catch bad pragma combination earlier X-Git-Tag: go1.9beta1~1172 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5f5d882f5cbd7f39d8bbbd5481a0884c0a042032;p=gostls13.git 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 Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/gc/noder.go b/src/cmd/compile/internal/gc/noder.go index df17b6ec21..80edeee710 100644 --- a/src/cmd/compile/internal/gc/noder.go +++ b/src/cmd/compile/internal/gc/noder.go @@ -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 diff --git a/src/cmd/compile/internal/gc/pgen.go b/src/cmd/compile/internal/gc/pgen.go index 4596086c7f..9d4003f35a 100644 --- a/src/cmd/compile/internal/gc/pgen.go +++ b/src/cmd/compile/internal/gc/pgen.go @@ -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.