"sort"
)
-func hidePanic() {
- if base.Debug.Panic == 0 && base.Errors() > 0 {
- // If we've already complained about things
- // in the program, don't bother complaining
- // about a panic too; let the user clean up
- // the code and try again.
- if err := recover(); err != nil {
- if err == "-h" {
- panic(err)
- }
- base.ErrorExit()
+// handlePanic ensures that we print out an "internal compiler error" for any panic
+// or runtime exception during front-end compiler processing (unless there have
+// already been some compiler errors). It may also be invoked from the explicit panic in
+// hcrash(), in which case, we pass the panic on through.
+func handlePanic() {
+ if err := recover(); err != nil {
+ if err == "-h" {
+ // Force real panic now with -h option (hcrash) - the error
+ // information will have already been printed.
+ panic(err)
}
+ base.Fatalf("panic: %v", err)
}
}
func Main(archInit func(*ssagen.ArchInfo)) {
base.Timer.Start("fe", "init")
- defer hidePanic()
+ defer handlePanic()
archInit(&ssagen.Arch)