From patchwork Tue Jun 22 22:21:18 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: 56576 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 66DD5B6F01 for ; Wed, 23 Jun 2010 08:21:42 +1000 (EST) Received: (qmail 4482 invoked by alias); 22 Jun 2010 22:21:40 -0000 Received: (qmail 4473 invoked by uid 22791); 22 Jun 2010 22:21:40 -0000 X-SWARE-Spam-Status: No, hits=-1.9 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) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Jun 2010 22:21:35 +0000 Received: from kpbe19.cbf.corp.google.com (kpbe19.cbf.corp.google.com [172.25.105.83]) by smtp-out.google.com with ESMTP id o5MMLWZZ009362 for ; Tue, 22 Jun 2010 15:21:32 -0700 Received: from pvc22 (pvc22.prod.google.com [10.241.209.150]) by kpbe19.cbf.corp.google.com with ESMTP id o5MMLUZX004855 for ; Tue, 22 Jun 2010 15:21:31 -0700 Received: by pvc22 with SMTP id 22so936632pvc.24 for ; Tue, 22 Jun 2010 15:21:30 -0700 (PDT) Received: by 10.115.101.22 with SMTP id d22mr6471727wam.136.1277245286786; Tue, 22 Jun 2010 15:21:26 -0700 (PDT) Received: from coign.google.com (dhcp-172-22-126-240.mtv.corp.google.com [172.22.126.240]) by mx.google.com with ESMTPS id d20sm29538485waa.15.2010.06.22.15.21.25 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 22 Jun 2010 15:21:26 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [gccgo] Permit trailing comma after call arguments From: Ian Lance Taylor Date: Tue, 22 Jun 2010 15:21:18 -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 Go permits a trailing comma after call arguments (e.g., "fn(1,)"). gccgo failed to implement that. This patch fixes it. Committed to gccgo branch. Ian diff -r d52e86ca34e6 go/parse.cc --- a/go/parse.cc Tue Jun 22 14:49:01 2010 -0700 +++ b/go/parse.cc Tue Jun 22 15:18:58 2010 -0700 @@ -141,7 +141,7 @@ if (!token->is_op(OPERATOR_COMMA)) return ret; - // A trailing comma is permitted in CompositeLit. + // Most expression lists permit a trailing comma. source_location location = token->location(); this->advance_token(); if (!this->expression_may_start_here()) @@ -2613,7 +2613,7 @@ return Expression::make_index(expr, start, end, location); } -// Call = "(" [ ExpressionList ] ")" . +// Call = "(" [ ExpressionList [ "," ] ] ")" . Expression* Parse::call(Expression* func) @@ -2626,6 +2626,8 @@ args = this->expression_list(NULL, false); token = this->peek_token(); } + if (token->is_op(OPERATOR_COMMA)) + token = this->advance_token(); if (!token->is_op(OPERATOR_RPAREN)) this->error("missing %<)%>"); else