This patch to the Go frontend avoids crashing the compiler when an
erroneous program causes it to attempt to build a type descriptor for an
unnamed integer type, or other types that should never be unnamed.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r 4b6a3ed61b80 go/types.cc
--- a/go/types.cc	Thu Feb 16 14:08:43 2012 -0800
+++ b/go/types.cc	Thu Feb 16 14:17:36 2012 -0800
@@ -2595,7 +2595,7 @@
 Expression*
 Integer_type::do_type_descriptor(Gogo* gogo, Named_type* name)
 {
-  go_assert(name != NULL);
+  go_assert(name != NULL || saw_errors());
   return this->plain_type_descriptor(gogo, this->runtime_type_kind_, name);
 }
 
@@ -2730,7 +2730,7 @@
 Expression*
 Float_type::do_type_descriptor(Gogo* gogo, Named_type* name)
 {
-  go_assert(name != NULL);
+  go_assert(name != NULL || saw_errors());
   return this->plain_type_descriptor(gogo, this->runtime_type_kind_, name);
 }
 
@@ -2857,7 +2857,7 @@
 Expression*
 Complex_type::do_type_descriptor(Gogo* gogo, Named_type* name)
 {
-  go_assert(name != NULL);
+  go_assert(name != NULL || saw_errors());
   return this->plain_type_descriptor(gogo, this->runtime_type_kind_, name);
 }
 

Reply via email to