Go patch committed: Don't crash initializing array of invalid type

Submitted by Ian Taylor on Dec. 15, 2010, 12:09 a.m.

Details

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

Commit Message

Ian Taylor Dec. 15, 2010, 12:09 a.m.
This patch to the Go frontend avoids crashing when zero-initializing an
array of an invalid type.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch hide | download patch | download mbox

diff -r 667e7f7457b5 go/types.cc
--- a/go/types.cc	Tue Dec 14 15:54:49 2010 -0800
+++ b/go/types.cc	Tue Dec 14 16:05:01 2010 -0800
@@ -4421,8 +4421,13 @@ 
       tree value = this->element_type_->get_init_tree(gogo, is_clear);
       if (value == NULL)
 	return NULL;
+      if (value == error_mark_node)
+	return error_mark_node;
 
       tree length_tree = this->get_length_tree(gogo);
+      if (length_tree == error_mark_node)
+	return error_mark_node;
+
       length_tree = fold_convert(sizetype, length_tree);
       tree range = build2(RANGE_EXPR, sizetype, size_zero_node,
 			  fold_build2(MINUS_EXPR, sizetype,