public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: Don't permit go/defer calls to be parenthesized
@ 2012-12-04  0:28 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2012-12-04  0:28 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 242 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 883 bytes --]

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;
     }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-04  0:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-04  0:28 Go patch committed: Don't permit go/defer calls to be parenthesized Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).