From 62d1a8f9040b90d1503a5495cf43b80027add792 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 23 Dec 2010 00:07:42 +0000 Subject: [PATCH] Avoid crash when an unknown object is declared as a type. From-SVN: r168188 --- gcc/go/gofrontend/expressions.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index ea5821b5685..8592ef546b9 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -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()) { -- 2.30.2