OSDN Git Service

Avoid crash when an unknown object is declared as a type.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Dec 2010 00:07:42 +0000 (00:07 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Dec 2010 00:07:42 +0000 (00:07 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168188 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/expressions.cc

index ea5821b..8592ef5 100644 (file)
@@ -1248,14 +1248,20 @@ Unknown_expression::do_lower(Gogo*, Named_object*, int)
 {
   source_location location = this->location();
   Named_object* no = this->named_object_;
 {
   source_location location = this->location();
   Named_object* no = this->named_object_;
-  Named_object* real = no->unknown_value()->real_named_object();
-  if (real == NULL)
+  Named_object* real;
+  if (!no->is_unknown())
+    real = no;
+  else
     {
     {
-      if (this->is_composite_literal_key_)
-       return this;
-      error_at(location, "reference to undefined name %qs",
-              this->named_object_->message_name().c_str());
-      return Expression::make_error(location);
+      real = no->unknown_value()->real_named_object();
+      if (real == NULL)
+       {
+         if (this->is_composite_literal_key_)
+           return this;
+         error_at(location, "reference to undefined name %qs",
+                  this->named_object_->message_name().c_str());
+         return Expression::make_error(location);
+       }
     }
   switch (real->classification())
     {
     }
   switch (real->classification())
     {