This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Don't crash when calling new on erroneous type
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Tue, 21 Dec 2010 15:19:45 -0800
- Subject: Go patch committed: Don't crash when calling new on erroneous type
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 -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);
}