Don't crash on invalid type conversion.
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 22 Dec 2010 06:17:55 +0000 (06:17 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 22 Dec 2010 06:17:55 +0000 (06:17 +0000)
From-SVN: r168161

gcc/go/gofrontend/expressions.cc

index 525ede2..114712b 100644 (file)
@@ -3242,6 +3242,18 @@ Type_conversion_expression::do_check_types(Gogo*)
   Type* expr_type = this->expr_->type();
   std::string reason;
 
+  if (type->is_error_type()
+      || type->is_undefined()
+      || expr_type->is_error_type()
+      || expr_type->is_undefined())
+    {
+      // Make sure we emit an error for an undefined type.
+      type->base();
+      expr_type->base();
+      this->set_is_error();
+      return;
+    }
+
   if (this->may_convert_function_types_
       && type->function_type() != NULL
       && expr_type->function_type() != NULL)