From patchwork Tue Dec 4 00:28:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Go patch committed: Don't permit go/defer calls to be parenthesized From: Ian Taylor X-Patchwork-Id: 203514 Message-Id: To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Date: Mon, 03 Dec 2012 16:28:33 -0800 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; }