This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Go patch committed: Don't permit go/defer calls to be parenthesized


The Go language spec does not permit go or defer calls to be
parenthesized, but gccgo was permitting it.  This patch issues an error
for that case.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r 4427b2edf858 go/parse.cc
--- a/go/parse.cc	Sun Dec 02 23:20:02 2012 -0800
+++ b/go/parse.cc	Mon Dec 03 16:26:16 2012 -0800
@@ -4089,13 +4089,16 @@
 	     || this->peek_token()->is_keyword(KEYWORD_DEFER));
   bool is_go = this->peek_token()->is_keyword(KEYWORD_GO);
   Location stat_location = this->location();
-  this->advance_token();
+
+  const Token* token = this->advance_token();
   Location expr_location = this->location();
+  bool is_parenthesized = token->is_op(OPERATOR_LPAREN);
+
   Expression* expr = this->expression(PRECEDENCE_NORMAL, false, true, NULL);
   Call_expression* call_expr = expr->call_expression();
-  if (call_expr == NULL)
-    {
-      error_at(expr_location, "expected call expression");
+  if (is_parenthesized || call_expr == NULL)
+    {
+      error_at(expr_location, "argument to go/defer must be function call");
       return;
     }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]