This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Traverse erroneous functions redefinitions
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Tue, 22 Feb 2011 20:56:43 -0800
- Subject: Go patch committed: Traverse erroneous functions redefinitions
This patch to the Go frontend ensures that the frontend traverses
erroneous function redefinitions. This ensures that they are lowered
as usual, which avoids some knock-on errors when definitions in them are
referenced by, e.g., nested functions within them. Bootstrapped and ran
Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r b0ad70eed034 go/gogo.cc
--- a/go/gogo.cc Tue Feb 22 20:52:58 2011 -0800
+++ b/go/gogo.cc Tue Feb 22 20:54:40 2011 -0800
@@ -682,10 +682,15 @@
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