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

login
register
mail settings
Submitter Ian Taylor
Date Dec. 15, 2010, 12:09 a.m.
Message ID <mcr8vzr7v81.fsf@google.com>
Download mbox | patch
Permalink /patch/75590/
State New
Headers show

Comments

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

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,