diff mbox

Go patch committed: Don't crash when calling new on erroneous type

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

Commit Message

Ian Lance Taylor Dec. 21, 2010, 11:19 p.m. UTC
This patch to the Go frontend avoids a crash when calling new with an
erroneous type.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 36326cbb6279 go/expressions.cc
--- a/go/expressions.cc	Tue Dec 21 15:11:44 2010 -0800
+++ b/go/expressions.cc	Tue Dec 21 15:15:40 2010 -0800
@@ -10242,9 +10242,13 @@ 
 Allocation_expression::do_get_tree(Translate_context* context)
 {
   tree type_tree = this->type_->get_tree(context->gogo());
+  if (type_tree == error_mark_node)
+    return error_mark_node;
   tree size_tree = TYPE_SIZE_UNIT(type_tree);
   tree space = context->gogo()->allocate_memory(this->type_, size_tree,
 						this->location());
+  if (space == error_mark_node)
+    return error_mark_node;
   return fold_convert(build_pointer_type(type_tree), space);
 }