diff mbox

[gccgo] Permit trailing comma after call arguments

Message ID mcrmxumk8td.fsf@dhcp-172-17-9-151.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor June 22, 2010, 10:21 p.m. UTC
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 mbox

Patch

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