aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-02-11 06:34:57 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-02-11 06:34:57 +0000
commitced2ec3b26ff0a64c3bbfdc1d0e47db1bc90d3a3 (patch)
tree0570bc9b010648b8cec52d7e17b413f268965819 /gcc
parent4a087ccf224d8cc2ba2e06571cd90a18408be4be (diff)
downloadgcc-ced2ec3b26ff0a64c3bbfdc1d0e47db1bc90d3a3.zip
gcc-ced2ec3b26ff0a64c3bbfdc1d0e47db1bc90d3a3.tar.gz
gcc-ced2ec3b26ff0a64c3bbfdc1d0e47db1bc90d3a3.tar.bz2
Don't get confused using type of erronous binary expression.
From-SVN: r170043
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/expressions.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 8e76516..96636c1 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -5412,6 +5412,9 @@ Binary_expression::do_discarding_value()
Type*
Binary_expression::do_type()
{
+ if (this->classification() == EXPRESSION_ERROR)
+ return Type::make_error_type();
+
switch (this->op_)
{
case OPERATOR_OROR:
@@ -5440,6 +5443,11 @@ Binary_expression::do_type()
return left_type;
else if (right_type->is_error_type())
return right_type;
+ else if (!Type::are_compatible_for_binop(left_type, right_type))
+ {
+ this->report_error(_("incompatible types in binary expression"));
+ return Type::make_error_type();
+ }
else if (!left_type->is_abstract() && left_type->named_type() != NULL)
return left_type;
else if (!right_type->is_abstract() && right_type->named_type() != NULL)
@@ -5667,6 +5675,9 @@ Binary_expression::check_operator_type(Operator op, Type* type,
void
Binary_expression::do_check_types(Gogo*)
{
+ if (this->classification() == EXPRESSION_ERROR)
+ return;
+
Type* left_type = this->left_->type();
Type* right_type = this->right_->type();
if (left_type->is_error_type() || right_type->is_error_type())