aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2010-12-22 06:27:50 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2010-12-22 06:27:50 +0000
commit8e6c2a27c533e2523dfcb28310aae7b6f1854edc (patch)
tree28e58eb0d2d9fe4e5225882a59307e85f3c9e852 /gcc/go
parentecdacbb3050849a2548475f0f632c13df0f38352 (diff)
downloadgcc-8e6c2a27c533e2523dfcb28310aae7b6f1854edc.zip
gcc-8e6c2a27c533e2523dfcb28310aae7b6f1854edc.tar.gz
gcc-8e6c2a27c533e2523dfcb28310aae7b6f1854edc.tar.bz2
Don't crash if a constant initializer refers to the constant.
From-SVN: r168162
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/expressions.cc5
-rw-r--r--gcc/go/gofrontend/gogo.cc4
2 files changed, 5 insertions, 4 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 114712b8..331238e 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -2528,7 +2528,9 @@ Const_expression::do_type()
if (this->type_ != NULL)
return this->type_;
- if (this->seen_)
+ Named_constant* nc = this->constant_->const_value();
+
+ if (this->seen_ || nc->lowering())
{
this->report_error(_("constant refers to itself"));
this->type_ = Type::make_error_type();
@@ -2537,7 +2539,6 @@ Const_expression::do_type()
this->seen_ = true;
- Named_constant* nc = this->constant_->const_value();
Type* ret = nc->type();
if (ret != NULL)
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc
index eb530d1..32d5589 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -1163,8 +1163,8 @@ Lower_parse_tree::constant(Named_object* no, bool)
{
Named_constant* nc = no->const_value();
- // We can recursively a constant if the initializer expression
- // manages to refer to itself.
+ // Don't get into trouble if the constant's initializer expression
+ // refers to the constant itself.
if (nc->lowering())
return TRAVERSE_CONTINUE;
nc->set_lowering();