Patchwork Go patch committed: Check for errors building map construction

login
register
mail settings
Submitter Ian Taylor
Date Dec. 22, 2010, midnight
Message ID <mcrsjxqk768.fsf@google.com>
Download mbox | patch
Permalink /patch/76349/
State New
Headers show

Comments

Ian Taylor - Dec. 22, 2010, midnight
This patch to the Go frontend checks for errors when building a map
construction.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 07f7aa430c8a go/expressions.cc
--- a/go/expressions.cc	Tue Dec 21 15:46:58 2010 -0800
+++ b/go/expressions.cc	Tue Dec 21 15:57:23 2010 -0800
@@ -11181,13 +11181,19 @@ 
 
   Type* key_type = mt->key_type();
   tree id = get_identifier("__key");
-  tree key_field = build_decl(loc, FIELD_DECL, id, key_type->get_tree(gogo));
+  tree key_type_tree = key_type->get_tree(gogo);
+  if (key_type_tree == error_mark_node)
+    return error_mark_node;
+  tree key_field = build_decl(loc, FIELD_DECL, id, key_type_tree);
   DECL_CONTEXT(key_field) = struct_type;
   TYPE_FIELDS(struct_type) = key_field;
 
   Type* val_type = mt->val_type();
   id = get_identifier("__val");
-  tree val_field = build_decl(loc, FIELD_DECL, id, val_type->get_tree(gogo));
+  tree val_type_tree = val_type->get_tree(gogo);
+  if (val_type_tree == error_mark_node)
+    return error_mark_node;
+  tree val_field = build_decl(loc, FIELD_DECL, id, val_type_tree);
   DECL_CONTEXT(val_field) = struct_type;
   DECL_CHAIN(key_field) = val_field;
 
@@ -11288,6 +11294,8 @@ 
   tree descriptor = gogo->map_descriptor(mt);
 
   tree type_tree = this->type_->get_tree(gogo);
+  if (type_tree == error_mark_node)
+    return error_mark_node;
 
   static tree construct_map_fndecl;
   tree call = Gogo::call_builtin(&construct_map_fndecl,