From: Josh Bleecher Snyder Date: Mon, 20 Mar 2017 20:16:07 +0000 (-0700) Subject: cmd/compile: check for missing function body earlier X-Git-Tag: go1.9beta1~1071 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0dafb7d9624c4c2bc876f03f2a6fa8d4a2ce6963;p=gostls13.git cmd/compile: check for missing function body earlier Tested by fixedbugs/issue3705.go. This removes a dependency on lineno from near the backend. Change-Id: I228bd0ad7295cf881b9bdeb0df9d18483fb96821 Reviewed-on: https://go-review.googlesource.com/38382 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/gc/noder.go b/src/cmd/compile/internal/gc/noder.go index a7f0ba54f0..41c05c6480 100644 --- a/src/cmd/compile/internal/gc/noder.go +++ b/src/cmd/compile/internal/gc/noder.go @@ -319,6 +319,10 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node { funcbody(f) + if f.Nbody.Len() == 0 && (pure_go || strings.HasPrefix(f.Func.Nname.Sym.Name, "init.")) { + yyerrorl(f.Pos, "missing function body for %q", f.Func.Nname.Sym.Name) + } + return f } diff --git a/src/cmd/compile/internal/gc/pgen.go b/src/cmd/compile/internal/gc/pgen.go index e588ab210c..6294c125c7 100644 --- a/src/cmd/compile/internal/gc/pgen.go +++ b/src/cmd/compile/internal/gc/pgen.go @@ -12,7 +12,6 @@ import ( "cmd/internal/sys" "fmt" "sort" - "strings" ) // "Portable" code generation. @@ -278,11 +277,6 @@ func compile(fn *Node) { dowidth(fn.Type) if fn.Nbody.Len() == 0 { - if pure_go || strings.HasPrefix(fn.Func.Nname.Sym.Name, "init.") { - yyerror("missing function body for %q", fn.Func.Nname.Sym.Name) - return - } - emitptrargsmap() return }