summaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2016-02-10 20:16:25 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2016-02-10 20:16:25 +0000
commitefdfa4676cd3506381bd987f7365767bb05c934a (patch)
treee8666879ccfb59066bec1568f2ac1b5ce42e75a1 /gcc/go
parenteb76579392e0d61b9f33c90fdd8b620e563d0a12 (diff)
downloadgcc-efdfa4676cd3506381bd987f7365767bb05c934a.tar.gz
2016-02-10 Basile Starynkevitch <basile@starynkevitch.net>
{{merging with even more of GCC 6, using subversion 1.9 svn merge -r227701:227820 ^/trunk }} git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@233307 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/expressions.cc41
2 files changed, 26 insertions, 17 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index ef21b544a5f..bcaabac4b9c 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-aea4360ca9c37f8e929f177ae7e42593ee62aa79
+01a574c1b2bb244be764b6a18aab980ca0aef43c
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index dc37cf0b01e..1c329b83050 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -5307,6 +5307,14 @@ Binary_expression::do_determine_type(const Type_context* context)
|| this->op_ == OPERATOR_GT
|| this->op_ == OPERATOR_GE);
+ // For constant expressions, the context of the result is not useful in
+ // determining the types of the operands. It is only legal to use abstract
+ // boolean, numeric, and string constants as operands where it is legal to
+ // use non-abstract boolean, numeric, and string constants, respectively.
+ // Any issues with the operation will be resolved in the check_types pass.
+ bool is_constant_expr = (this->left_->is_constant()
+ && this->right_->is_constant());
+
Type_context subcontext(*context);
if (is_comparison)
@@ -5351,7 +5359,8 @@ Binary_expression::do_determine_type(const Type_context* context)
subcontext.type = subcontext.type->make_non_abstract_type();
}
- this->left_->determine_type(&subcontext);
+ if (!is_constant_expr)
+ this->left_->determine_type(&subcontext);
if (is_shift_op)
{
@@ -5371,7 +5380,8 @@ Binary_expression::do_determine_type(const Type_context* context)
subcontext.may_be_abstract = false;
}
- this->right_->determine_type(&subcontext);
+ if (!is_constant_expr)
+ this->right_->determine_type(&subcontext);
if (is_comparison)
{
@@ -5396,7 +5406,8 @@ Binary_expression::check_operator_type(Operator op, Type* type, Type* otype,
{
case OPERATOR_OROR:
case OPERATOR_ANDAND:
- if (!type->is_boolean_type())
+ if (!type->is_boolean_type()
+ || !otype->is_boolean_type())
{
error_at(location, "expected boolean type");
return false;
@@ -5431,10 +5442,8 @@ Binary_expression::check_operator_type(Operator op, Type* type, Type* otype,
case OPERATOR_PLUS:
case OPERATOR_PLUSEQ:
- if (type->integer_type() == NULL
- && type->float_type() == NULL
- && type->complex_type() == NULL
- && !type->is_string_type())
+ if ((!type->is_numeric_type() && !type->is_string_type())
+ || (!otype->is_numeric_type() && !otype->is_string_type()))
{
error_at(location,
"expected integer, floating, complex, or string type");
@@ -5448,9 +5457,7 @@ Binary_expression::check_operator_type(Operator op, Type* type, Type* otype,
case OPERATOR_MULTEQ:
case OPERATOR_DIV:
case OPERATOR_DIVEQ:
- if (type->integer_type() == NULL
- && type->float_type() == NULL
- && type->complex_type() == NULL)
+ if (!type->is_numeric_type() || !otype->is_numeric_type())
{
error_at(location, "expected integer, floating, or complex type");
return false;
@@ -5467,7 +5474,7 @@ Binary_expression::check_operator_type(Operator op, Type* type, Type* otype,
case OPERATOR_XOREQ:
case OPERATOR_BITCLEAR:
case OPERATOR_BITCLEAREQ:
- if (type->integer_type() == NULL)
+ if (type->integer_type() == NULL || otype->integer_type() == NULL)
{
error_at(location, "expected integer type");
return false;
@@ -6878,11 +6885,6 @@ Builtin_call_expression::do_flatten(Gogo*, Named_object*,
Statement_inserter* inserter)
{
Location loc = this->location();
- if (this->is_erroneous_call())
- {
- go_assert(saw_errors());
- return Expression::make_error(loc);
- }
switch (this->code_)
{
@@ -8057,6 +8059,13 @@ Builtin_call_expression::do_get_backend(Translate_context* context)
{
Gogo* gogo = context->gogo();
Location location = this->location();
+
+ if (this->is_erroneous_call())
+ {
+ go_assert(saw_errors());
+ return gogo->backend()->error_expression();
+ }
+
switch (this->code_)
{
case BUILTIN_INVALID: