diff mbox

Go patch committed: Don't crash if a named constant has no type

Message ID mcr7hekpgmc.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Jan. 4, 2011, 8:18 p.m. UTC
When compiling invalid code it's possible for the type to never be set
for a named constant.  All the cases which care check for NULL except
one.  This patch fixes the final case.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 6f834ce27f8b go/expressions.cc
--- a/go/expressions.cc	Tue Jan 04 11:45:52 2011 -0800
+++ b/go/expressions.cc	Tue Jan 04 12:15:47 2011 -0800
@@ -2680,7 +2680,8 @@ 
   // object is an abstract int or float, we try to get the abstract
   // value.  Otherwise we may lose something in the conversion.
   if (this->type_ != NULL
-      && this->constant_->const_value()->type()->is_abstract())
+      && (this->constant_->const_value()->type() == NULL
+	  || this->constant_->const_value()->type()->is_abstract()))
     {
       Expression* expr = this->constant_->const_value()->expr();
       mpz_t ival;