Traverse erroneous function redefinitions.
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 23 Feb 2011 04:57:01 +0000 (04:57 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 23 Feb 2011 04:57:01 +0000 (04:57 +0000)
From-SVN: r170428

gcc/go/gofrontend/gogo.cc

index 0be8c66a83b60d138bca8252adc75b5c37069428..b062c541a698706519fbf1a1944b29abf4980814 100644 (file)
@@ -682,10 +682,15 @@ Gogo::start_function(const std::string& name, Function_type* type,
   else if (!type->is_method())
     {
       ret = this->package_->bindings()->add_function(*pname, NULL, function);
-      if (!ret->is_function())
+      if (!ret->is_function() || ret->func_value() != function)
        {
-         // Redefinition error.
-         ret = Named_object::make_function(name, NULL, function);
+         // Redefinition error.  Invent a name to avoid knockon
+         // errors.
+         static int redefinition_count;
+         char buf[30];
+         snprintf(buf, sizeof buf, ".$redefined%d", redefinition_count);
+         ++redefinition_count;
+         ret = this->package_->bindings()->add_function(buf, NULL, function);
        }
     }
   else