aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2017-10-13 14:47:45 -0700
committerRuss Cox <rsc@golang.org>2017-10-25 20:23:36 +0000
commitd487b15a61eee87c304277842a4624dca0c6bddd (patch)
tree5ff402ac21c24a91e0e833b98b9cf046c610e9df
parentfd17253587862248ee9a30a89e59db2fa9b77d1d (diff)
downloadgo-d487b15a61eee87c304277842a4624dca0c6bddd.tar.gz
go-d487b15a61eee87c304277842a4624dca0c6bddd.zip
[release-branch.go1.9] cmd/compile: omit ICE diagnostics after normal error messages
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> Reviewed-on: https://go-review.googlesource.com/70985 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
-rw-r--r--src/cmd/compile/internal/gc/subr.go28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go
index d79789c4fe..047acee05f 100644
--- a/src/cmd/compile/internal/gc/subr.go
+++ b/src/cmd/compile/internal/gc/subr.go
@@ -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()