From patchwork Fri Jun 25 05:58:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 56890 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A361DB6F44 for ; Fri, 25 Jun 2010 15:59:09 +1000 (EST) Received: (qmail 27764 invoked by alias); 25 Jun 2010 05:59:07 -0000 Received: (qmail 27755 invoked by uid 22791); 25 Jun 2010 05:59:06 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Jun 2010 05:59:00 +0000 Received: from kpbe18.cbf.corp.google.com (kpbe18.cbf.corp.google.com [172.25.105.82]) by smtp-out.google.com with ESMTP id o5P5wwpB019354 for ; Thu, 24 Jun 2010 22:58:58 -0700 Received: from pvh1 (pvh1.prod.google.com [10.241.210.193]) by kpbe18.cbf.corp.google.com with ESMTP id o5P5wcmw001173 for ; Thu, 24 Jun 2010 22:58:39 -0700 Received: by pvh1 with SMTP id 1so1286124pvh.30 for ; Thu, 24 Jun 2010 22:58:38 -0700 (PDT) Received: by 10.142.66.11 with SMTP id o11mr209558wfa.121.1277445518548; Thu, 24 Jun 2010 22:58:38 -0700 (PDT) Received: from coign.google.com ([216.239.45.130]) by mx.google.com with ESMTPS id i19sm46641rvn.4.2010.06.24.22.58.37 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 24 Jun 2010 22:58:37 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [gccgo] Don't export top level function literals From: Ian Lance Taylor Date: Thu, 24 Jun 2010 22:58:35 -0700 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 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;