Commit 8e6c2a27 by Ian Lance Taylor

Don't crash if a constant initializer refers to the constant.

From-SVN: r168162
parent ecdacbb3
...@@ -2528,7 +2528,9 @@ Const_expression::do_type() ...@@ -2528,7 +2528,9 @@ Const_expression::do_type()
if (this->type_ != NULL) if (this->type_ != NULL)
return this->type_; 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->report_error(_("constant refers to itself"));
this->type_ = Type::make_error_type(); this->type_ = Type::make_error_type();
...@@ -2537,7 +2539,6 @@ Const_expression::do_type() ...@@ -2537,7 +2539,6 @@ Const_expression::do_type()
this->seen_ = true; this->seen_ = true;
Named_constant* nc = this->constant_->const_value();
Type* ret = nc->type(); Type* ret = nc->type();
if (ret != NULL) if (ret != NULL)
......
...@@ -1163,8 +1163,8 @@ Lower_parse_tree::constant(Named_object* no, bool) ...@@ -1163,8 +1163,8 @@ Lower_parse_tree::constant(Named_object* no, bool)
{ {
Named_constant* nc = no->const_value(); Named_constant* nc = no->const_value();
// We can recursively a constant if the initializer expression // Don't get into trouble if the constant's initializer expression
// manages to refer to itself. // refers to the constant itself.
if (nc->lowering()) if (nc->lowering())
return TRAVERSE_CONTINUE; return TRAVERSE_CONTINUE;
nc->set_lowering(); nc->set_lowering();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment