aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2014-04-17 19:10:27 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2014-04-17 19:10:27 +0000
commit39be2171e0fa8da0d5bbfd3aecd11f5709f8f309 (patch)
treec429a9855c58a915da40e7a6d799948153afb0d0
parent5e750dc69f9e2580bed0d45bd0383622cc272b39 (diff)
downloadgcc-39be2171e0fa8da0d5bbfd3aecd11f5709f8f309.zip
gcc-39be2171e0fa8da0d5bbfd3aecd11f5709f8f309.tar.gz
gcc-39be2171e0fa8da0d5bbfd3aecd11f5709f8f309.tar.bz2
compiler: Define immutability for numeric, constant, type info, type conversion, and addressof expressions.
From-SVN: r209493
-rw-r--r--gcc/go/gofrontend/expressions.cc55
1 files changed, 54 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index bd2e318..1994610 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -555,6 +555,10 @@ class Error_expression : public Expression
{ return true; }
bool
+ do_is_immutable() const
+ { return true; }
+
+ bool
do_numeric_constant_value(Numeric_constant* nc) const
{
nc->set_unsigned_long(NULL, 0);
@@ -1422,6 +1426,10 @@ class Boolean_expression : public Expression
do_is_constant() const
{ return true; }
+ bool
+ do_is_immutable() const
+ { return true; }
+
Type*
do_type();
@@ -1790,6 +1798,10 @@ class Integer_expression : public Expression
{ return true; }
bool
+ do_is_immutable() const
+ { return true; }
+
+ bool
do_numeric_constant_value(Numeric_constant* nc) const;
Type*
@@ -2109,6 +2121,10 @@ class Float_expression : public Expression
{ return true; }
bool
+ do_is_immutable() const
+ { return true; }
+
+ bool
do_numeric_constant_value(Numeric_constant* nc) const
{
nc->set_float(this->type_, this->val_);
@@ -2292,6 +2308,10 @@ class Complex_expression : public Expression
{ return true; }
bool
+ do_is_immutable() const
+ { return true; }
+
+ bool
do_numeric_constant_value(Numeric_constant* nc) const
{
nc->set_complex(this->type_, this->real_, this->imag_);
@@ -2506,6 +2526,10 @@ class Const_expression : public Expression
{ return true; }
bool
+ do_is_immutable() const
+ { return true; }
+
+ bool
do_numeric_constant_value(Numeric_constant* nc) const;
bool
@@ -2994,6 +3018,9 @@ class Type_conversion_expression : public Expression
do_is_constant() const;
bool
+ do_is_immutable() const;
+
+ bool
do_numeric_constant_value(Numeric_constant*) const;
bool
@@ -3175,6 +3202,27 @@ Type_conversion_expression::do_is_constant() const
return true;
}
+// Return whether a type conversion is immutable.
+
+bool
+Type_conversion_expression::do_is_immutable() const
+{
+ Type* type = this->type_;
+ Type* expr_type = this->expr_->type();
+
+ if (type->interface_type() != NULL
+ || expr_type->interface_type() != NULL)
+ return false;
+
+ if (!this->expr_->is_immutable())
+ return false;
+
+ if (Type::are_identical(type, expr_type, false, NULL))
+ return true;
+
+ return type->is_basic_type() && expr_type->is_basic_type();
+}
+
// Return the constant numeric value if there is one.
bool
@@ -3599,7 +3647,8 @@ class Unary_expression : public Expression
bool
do_is_immutable() const
- { return this->expr_->is_immutable(); }
+ { return this->expr_->is_immutable()
+ || (this->op_ == OPERATOR_AND && this->expr_->is_variable()); }
bool
do_numeric_constant_value(Numeric_constant*) const;
@@ -14076,6 +14125,10 @@ class Type_info_expression : public Expression
{ }
protected:
+ bool
+ do_is_immutable() const
+ { return true; }
+
Type*
do_type();