]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid crash when an unknown object is declared as a type.
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 23 Dec 2010 00:07:42 +0000 (00:07 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 23 Dec 2010 00:07:42 +0000 (00:07 +0000)
From-SVN: r168188

gcc/go/gofrontend/expressions.cc

index ea5821b56857f1404228083706e580bf3423a4c0..8592ef546b9b5534e2908d1f510cf795226dfa18 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_;
-  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())
     {