]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Don't crash if a constant initializer refers to the constant.
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 22 Dec 2010 06:27:50 +0000 (06:27 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 22 Dec 2010 06:27:50 +0000 (06:27 +0000)
From-SVN: r168162

gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/gogo.cc

index 114712b8591e55bb8108ec8132d66394aa61e4f3..331238e638eaf9854baffe85be5e33fbc80f0c25 100644 (file)
@@ -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)
index eb530d1eb9c3c32ed9af40f69e86e69612b903f4..32d5589feea0aba514cc82806590c580f11742d4 100644 (file)
@@ -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();