From patchwork Tue Jun 22 22:21:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [gccgo] Permit trailing comma after call arguments Date: Tue, 22 Jun 2010 12:21:18 -0000 From: Ian Taylor X-Patchwork-Id: 56576 Message-Id: To: 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