From patchwork Tue Dec 21 23:13:20 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: 76342 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 3B24DB70A4 for ; Wed, 22 Dec 2010 10:13:39 +1100 (EST) Received: (qmail 5113 invoked by alias); 21 Dec 2010 23:13:34 -0000 Received: (qmail 5089 invoked by uid 22791); 21 Dec 2010 23:13:32 -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; Tue, 21 Dec 2010 23:13:27 +0000 Received: from hpaq13.eem.corp.google.com (hpaq13.eem.corp.google.com [172.25.149.13]) by smtp-out.google.com with ESMTP id oBLNDPLP018477 for ; Tue, 21 Dec 2010 15:13:25 -0800 Received: from pwj3 (pwj3.prod.google.com [10.241.219.67]) by hpaq13.eem.corp.google.com with ESMTP id oBLNDN61008511 for ; Tue, 21 Dec 2010 15:13:24 -0800 Received: by pwj3 with SMTP id 3so214262pwj.33 for ; Tue, 21 Dec 2010 15:13:23 -0800 (PST) Received: by 10.142.162.21 with SMTP id k21mr4993698wfe.412.1292973202940; Tue, 21 Dec 2010 15:13:22 -0800 (PST) Received: from coign.google.com (dhcp-172-22-122-207.mtv.corp.google.com [172.22.122.207]) by mx.google.com with ESMTPS id v19sm8211456wfh.0.2010.12.21.15.13.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 21 Dec 2010 15:13:22 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Don't crash returning from '_' function Date: Tue, 21 Dec 2010 15:13:20 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.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 The name '_' in Go is special and means that the object is ignored. It is possible to name a function '_'. Gccgo would crash when a function with that name had a return statement. This patch fixes the crash by giving the function a real name internally. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r b430e050bd97 go/gogo.cc --- a/go/gogo.cc Tue Dec 21 14:57:39 2010 -0800 +++ b/go/gogo.cc Tue Dec 21 15:06:39 2010 -0800 @@ -659,7 +659,13 @@ Named_object* ret; if (Gogo::is_sink_name(*pname)) - ret = Named_object::make_sink(); + { + static int sink_count; + char buf[30]; + snprintf(buf, sizeof buf, ".$sink%d", sink_count); + ++sink_count; + ret = Named_object::make_function(buf, NULL, function); + } else if (!type->is_method()) { ret = this->package_->bindings()->add_function(*pname, NULL, function);