Don't crash when some object is redefined as a type.
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 21 Dec 2010 18:20:51 +0000 (18:20 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 21 Dec 2010 18:20:51 +0000 (18:20 +0000)
From-SVN: r168126

gcc/go/gofrontend/gogo.cc

index 8ba1d4fab68ae36747a7a6b9e43991109b423225..d5db85c6d19e3819bf51958aa49c253571ee7597 100644 (file)
@@ -881,7 +881,7 @@ Gogo::add_type(const std::string& name, Type* type, source_location location)
 {
   Named_object* no = this->current_bindings()->add_type(name, NULL, type,
                                                        location);
-  if (!this->in_global_scope())
+  if (!this->in_global_scope() && no->is_type())
     no->type_value()->set_in_function(this->functions_.back().function);
 }
 
@@ -901,7 +901,7 @@ Gogo::declare_type(const std::string& name, source_location location)
 {
   Bindings* bindings = this->current_bindings();
   Named_object* no = bindings->add_type_declaration(name, NULL, location);
-  if (!this->in_global_scope())
+  if (!this->in_global_scope() && no->is_type_declaration())
     {
       Named_object* f = this->functions_.back().function;
       no->type_declaration_value()->set_in_function(f);