From patchwork Wed Dec 15 22:42:33 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: 75701 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 D7B6F1007D9 for ; Thu, 16 Dec 2010 09:42:52 +1100 (EST) Received: (qmail 19006 invoked by alias); 15 Dec 2010 22:42:46 -0000 Received: (qmail 18945 invoked by uid 22791); 15 Dec 2010 22:42:45 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, 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) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 15 Dec 2010 22:42:40 +0000 Received: from wpaz33.hot.corp.google.com (wpaz33.hot.corp.google.com [172.24.198.97]) by smtp-out.google.com with ESMTP id oBFMgbOD032143 for ; Wed, 15 Dec 2010 14:42:37 -0800 Received: from gyh20 (gyh20.prod.google.com [10.243.50.212]) by wpaz33.hot.corp.google.com with ESMTP id oBFMgG7w023916 for ; Wed, 15 Dec 2010 14:42:36 -0800 Received: by gyh20 with SMTP id 20so1347749gyh.34 for ; Wed, 15 Dec 2010 14:42:36 -0800 (PST) Received: by 10.151.148.21 with SMTP id a21mr10913106ybo.93.1292452956328; Wed, 15 Dec 2010 14:42:36 -0800 (PST) Received: from coign.google.com (dhcp-172-22-127-241.mtv.corp.google.com [172.22.127.241]) by mx.google.com with ESMTPS id j63sm1016976yha.18.2010.12.15.14.42.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 15 Dec 2010 14:42:36 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Fix invalid signature in function literal Date: Wed, 15 Dec 2010 14:42:33 -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 This patch to the Go frontend fixes the way we handle an invalid signature for a function literal. Rather than trying to parse the block without creating a function, which fails if there is a return statement, we instead just create a dummy function type. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 70dbc32f9149 go/parse.cc --- a/go/parse.cc Wed Dec 15 14:30:06 2010 -0800 +++ b/go/parse.cc Wed Dec 15 14:38:25 2010 -0800 @@ -2513,10 +2513,7 @@ Function_type* type = this->signature(NULL, location); if (type == NULL) - { - this->block(); - return Expression::make_error(location); - } + type = Type::make_function_type(NULL, NULL, NULL, location); // For a function literal, the next token must be a '{'. If we // don't see that, then we may have a type expression.