Patchwork Go patch committed: Don't create erroroneous COND_EXPR

login
register
mail settings
Submitter Ian Taylor
Date Jan. 4, 2011, 10:15 p.m.
Message ID <mcry670nwmj.fsf@google.com>
Download mbox | patch
Permalink /patch/77540/
State New
Headers show

Comments

Ian Taylor - Jan. 4, 2011, 10:15 p.m.
This patch to the Go frontend avoids creating a COND_EXPR with
components which are error_mark_node.  Bootstrapped and ran Go testsuite
on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r e47e715f0459 go/statements.cc
--- a/go/statements.cc	Tue Jan 04 13:15:01 2011 -0800
+++ b/go/statements.cc	Tue Jan 04 14:13:07 2011 -0800
@@ -2985,14 +2985,19 @@ 
 If_statement::do_get_tree(Translate_context* context)
 {
   gcc_assert(this->cond_ == NULL || this->cond_->type()->is_boolean_type());
-  tree ret = build3(COND_EXPR, void_type_node,
-		    (this->cond_ == NULL
-		     ? boolean_true_node
-		     : this->cond_->get_tree(context)),
-		    this->then_block_->get_tree(context),
-		    (this->else_block_ == NULL
-		     ? NULL_TREE
-		     : this->else_block_->get_tree(context)));
+  tree cond_tree = (this->cond_ == NULL
+		    ? boolean_true_node
+		    : this->cond_->get_tree(context));
+  tree then_tree = this->then_block_->get_tree(context);
+  tree else_tree = (this->else_block_ == NULL
+		    ? NULL_TREE
+		    : this->else_block_->get_tree(context));
+  if (cond_tree == error_mark_node
+      || then_tree == error_mark_node
+      || else_tree == error_mark_node)
+    return error_mark_node;
+  tree ret = build3(COND_EXPR, void_type_node, cond_tree, then_tree,
+		    else_tree);
   SET_EXPR_LOCATION(ret, this->location());
   return ret;
 }