From ced2ec3b26ff0a64c3bbfdc1d0e47db1bc90d3a3 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor <ian@gcc.gnu.org>
Date: Fri, 11 Feb 2011 06:34:57 +0000
Subject: [PATCH] Don't get confused using type of erronous binary expression.

From-SVN: r170043
---
 gcc/go/gofrontend/expressions.cc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 8e7651636a56..96636c1b2331 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())
-- 
GitLab