Patchwork [gccgo] Don't export top level function literals

login
register
mail settings
Submitter Ian Taylor
Date June 25, 2010, 5:58 a.m.
Message ID <mcrocezac1g.fsf@dhcp-172-17-9-151.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/56890/
State New
Headers show

Comments

Ian Taylor - June 25, 2010, 5:58 a.m.
Given code like

var Usage = func() {
	fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
	PrintDefaults()
}

gccgo was exporting the function literal under the name __nested1.
That makes no sense.  Fixed with this patch which also avoids
namespace issues.  Committed to gccgo branch.

Ian

Patch

diff -r 35f170b775c0 go/gogo.cc
--- a/go/gogo.cc	Thu Jun 24 12:42:10 2010 -0700
+++ b/go/gogo.cc	Thu Jun 24 22:55:28 2010 -0700
@@ -608,7 +608,7 @@ 
       // Invent a name for a nested function.
       static int nested_count;
       char buf[30];
-      snprintf(buf, sizeof buf, "__nested%d", nested_count);
+      snprintf(buf, sizeof buf, ".$nested%d", nested_count);
       ++nested_count;
       nested_name = buf;
       pname = &nested_name;