diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-24 19:33:52 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-24 19:33:52 +0000 |
commit | fd9df055b2797a204531db1f846f7ef194bb6d0c (patch) | |
tree | cf4e1c1f6f1ee600592085723bfedbb46c43bf61 | |
parent | 2c49569ecea56dc875035dfaf1984f4746c9c46e (diff) | |
download | gcc-fd9df055b2797a204531db1f846f7ef194bb6d0c.zip gcc-fd9df055b2797a204531db1f846f7ef194bb6d0c.tar.gz gcc-fd9df055b2797a204531db1f846f7ef194bb6d0c.tar.bz2 |
compiler: Correct type of expressions involving character constants.
From-SVN: r183490
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 447e652..423df9c 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -5556,7 +5556,9 @@ Binary_expression::do_lower(Gogo* gogo, Named_object*, Expression* ret = NULL; if (left_type != right_type && left_type != NULL + && !left_type->is_abstract() && right_type != NULL + && !right_type->is_abstract() && left_type->base() != right_type->base() && op != OPERATOR_LSHIFT && op != OPERATOR_RSHIFT) @@ -5608,7 +5610,27 @@ Binary_expression::do_lower(Gogo* gogo, Named_object*, type = right_type; else type = left_type; - ret = Expression::make_integer(&val, type, location); + + bool is_character = false; + if (type == NULL) + { + Type* t = this->left_->type(); + if (t->integer_type() != NULL + && t->integer_type()->is_rune()) + is_character = true; + else if (op != OPERATOR_LSHIFT && op != OPERATOR_RSHIFT) + { + t = this->right_->type(); + if (t->integer_type() != NULL + && t->integer_type()->is_rune()) + is_character = true; + } + } + + if (is_character) + ret = Expression::make_character(&val, type, location); + else + ret = Expression::make_integer(&val, type, location); } mpz_clear(val); @@ -6252,6 +6274,12 @@ Binary_expression::do_type() return left_type; else if (right_type->float_type() != NULL) return right_type; + else if (left_type->integer_type() != NULL + && left_type->integer_type()->is_rune()) + return left_type; + else if (right_type->integer_type() != NULL + && right_type->integer_type()->is_rune()) + return right_type; else return left_type; } |