aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2010-12-14 23:34:14 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2010-12-14 23:34:14 +0000
commit173fb2ff62e71fe86e311cd7135da4383060ff64 (patch)
treec54ecc0ae5a23b3d8e9daa01e62695fb2b33f031
parent5262c72ad4f6c5895f1318935dfa8980050ce784 (diff)
downloadgcc-173fb2ff62e71fe86e311cd7135da4383060ff64.zip
gcc-173fb2ff62e71fe86e311cd7135da4383060ff64.tar.gz
gcc-173fb2ff62e71fe86e311cd7135da4383060ff64.tar.bz2
Don't try to build unary and binary expressions with invalid types.
From-SVN: r167824
-rw-r--r--gcc/go/gofrontend/expressions.cc42
1 files changed, 20 insertions, 22 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index d3f77ad..7041cb5 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -3824,29 +3824,28 @@ Unary_expression::do_determine_type(const Type_context* context)
void
Unary_expression::do_check_types(Gogo*)
{
+ Type* type = this->expr_->type();
+ if (type->is_error_type())
+ {
+ this->set_is_error();
+ return;
+ }
+
switch (this->op_)
{
case OPERATOR_PLUS:
case OPERATOR_MINUS:
- {
- Type* type = this->expr_->type();
- if (type->integer_type() == NULL
- && type->float_type() == NULL
- && type->complex_type() == NULL
- && !type->is_error_type())
- this->report_error(_("expected numeric type"));
- }
+ if (type->integer_type() == NULL
+ && type->float_type() == NULL
+ && type->complex_type() == NULL)
+ this->report_error(_("expected numeric type"));
break;
case OPERATOR_NOT:
case OPERATOR_XOR:
- {
- Type* type = this->expr_->type();
- if (type->integer_type() == NULL
- && !type->is_boolean_type()
- && !type->is_error_type())
- this->report_error(_("expected integer or boolean type"));
- }
+ if (type->integer_type() == NULL
+ && !type->is_boolean_type())
+ this->report_error(_("expected integer or boolean type"));
break;
case OPERATOR_AND:
@@ -3858,12 +3857,8 @@ Unary_expression::do_check_types(Gogo*)
case OPERATOR_MULT:
// Indirecting through a pointer.
- {
- Type* type = this->expr_->type();
- if (type->points_to() == NULL
- && !type->is_error_type())
- this->report_error(_("expected pointer"));
- }
+ if (type->points_to() == NULL)
+ this->report_error(_("expected pointer"));
break;
default:
@@ -5474,7 +5469,10 @@ Binary_expression::do_check_types(Gogo*)
Type* left_type = this->left_->type();
Type* right_type = this->right_->type();
if (left_type->is_error_type() || right_type->is_error_type())
- return;
+ {
+ this->set_is_error();
+ return;
+ }
if (this->op_ == OPERATOR_EQEQ
|| this->op_ == OPERATOR_NOTEQ