This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Don't create erroroneous COND_EXPR
- 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, 04 Jan 2011 14:15:48 -0800
- Subject: Go patch committed: Don't create erroroneous COND_EXPR
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
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;
}