]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: omit ICE diagnostics after normal error messages
authorMatthew Dempsky <mdempsky@google.com>
Fri, 13 Oct 2017 21:47:45 +0000 (14:47 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Sat, 14 Oct 2017 01:00:31 +0000 (01:00 +0000)
After we detect errors, the AST is in a precarious state and more
likely to trip useless ICE failures. Instead let the user fix any
existing errors and see if the ICE persists.  This makes Fatalf more
consistent with how panics are handled by hidePanic.

While here, also fix detection for release versions: release version
strings begin with "go" ("go1.8", "go1.9.1", etc), not "release".

Fixes #22252.

Change-Id: I1c400af62fb49dd979b96e1bf0fb295a81c8b336
Reviewed-on: https://go-review.googlesource.com/70850
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/compile/internal/gc/subr.go

index 5b0a06d21c96d342c69878604c231505fd079f50..81e5bd7e6e7c11434b5bf59d88652e2bc1af885d 100644 (file)
@@ -166,20 +166,22 @@ func Warnl(line src.XPos, fmt_ string, args ...interface{}) {
 func Fatalf(fmt_ string, args ...interface{}) {
        flusherrors()
 
-       fmt.Printf("%v: internal compiler error: ", linestr(lineno))
-       fmt.Printf(fmt_, args...)
-       fmt.Printf("\n")
-
-       // If this is a released compiler version, ask for a bug report.
-       if strings.HasPrefix(objabi.Version, "release") {
+       if Debug_panic != 0 || nsavederrors+nerrors == 0 {
+               fmt.Printf("%v: internal compiler error: ", linestr(lineno))
+               fmt.Printf(fmt_, args...)
                fmt.Printf("\n")
-               fmt.Printf("Please file a bug report including a short program that triggers the error.\n")
-               fmt.Printf("https://golang.org/issue/new\n")
-       } else {
-               // Not a release; dump a stack trace, too.
-               fmt.Println()
-               os.Stdout.Write(debug.Stack())
-               fmt.Println()
+
+               // If this is a released compiler version, ask for a bug report.
+               if strings.HasPrefix(objabi.Version, "go") {
+                       fmt.Printf("\n")
+                       fmt.Printf("Please file a bug report including a short program that triggers the error.\n")
+                       fmt.Printf("https://golang.org/issue/new\n")
+               } else {
+                       // Not a release; dump a stack trace, too.
+                       fmt.Println()
+                       os.Stdout.Write(debug.Stack())
+                       fmt.Println()
+               }
        }
 
        hcrash()