From patchwork Tue Oct 9 21:22:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 190455 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 350F72C00A4 for ; Wed, 10 Oct 2012 08:22:55 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1350422575; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Cc:Subject:References:Date:In-Reply-To: Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=enZVz4QjNyznlfBYz5KL56Harpc=; b=AZqo66sxrYQurtH3s9K6NR48Jg0DAwmEFAnWhLi9k0+KEUZKfmBeZyj0Y64rBR 0YjKD8CdJQfypUBroyb+mQp+4zcwOUoolOhF99vZUxxao3WIrCGEAJcx4nuxARZt bdKnB+dKcGeyY4/tjt+my8YKjdWy969j6msPnaNfCIuao= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Cc:Subject:References:X-URL:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=j+YduMyoKferlTIrPeNeJc6PW7PLC1CsdDvENi2MC3envm3QJy/dla/VVLRwet LzUYYnXhaZlfQH9HUmcBgQHIXQfWWrn0xmAGmD0hh5L8yHqY+M7gIhZRDd2lrt1o eBiExGImRo2mQrgi3rCEOJdWgtqZTjV5kazgzN2p4Wbvc=; Received: (qmail 23662 invoked by alias); 9 Oct 2012 21:22:50 -0000 Received: (qmail 23651 invoked by uid 22791); 9 Oct 2012 21:22:48 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Oct 2012 21:22:44 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q99LMi4h009150 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Oct 2012 17:22:44 -0400 Received: from localhost (ovpn-116-43.ams2.redhat.com [10.36.116.43]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q99LMhYt009603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 9 Oct 2012 17:22:44 -0400 Received: by localhost (Postfix, from userid 1000) id 6F4DE9F164; Tue, 9 Oct 2012 23:22:42 +0200 (CEST) From: Dodji Seketeli To: GCC Patches Cc: Jason Merrill Subject: [PATCH 1/3] Disambiguate nested objc-message-expressions and c++11 attributes References: <87wqyze40h.fsf@redhat.com> X-URL: http://www.redhat.com Date: Tue, 09 Oct 2012 23:22:42 +0200 In-Reply-To: <87wqyze40h.fsf@redhat.com> (Dodji Seketeli's message of "Tue, 09 Oct 2012 23:20:46 +0200") Message-ID: <87sj9ne3x9.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello, A couple of obj-c++ tests were failing[1] because the tokens '[[' can either be the beginning of a c++11 attribute (that is itself at the beginning of a statement), or the beginning of a nested objc-message-expression. This patch resolves the ambiguity by tentatively parsing the c++11 attribute and if it fails, then consider the objc-message-expression. I missed this initially because it didn't occur to me that --enable-languages=all,ada does not include obj-c++. Shame on me. I have now updated my compile farm scripts to use --enable-language=all,ada,obj-c++,go and I [1]: FAIL: obj-c++.dg/syntax-error-6.mm -fgnu-runtime (test for errors, line 11) FAIL: obj-c++.dg/syntax-error-6.mm -fgnu-runtime (test for excess errors) FAIL: obj-c++.dg/template-8.mm -fgnu-runtime (test for excess errors) Tested on x86_64-unknown-linux-gnu against trunk. gcc/cp/ * parser (cp_parser_statement): Parse c++11 attributes tentatively. (cp_parser_std_attribute_spec_seq): Do not warn too early about using c++11 attributes in non c++11 mode. --- gcc/cp/parser.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 52a152d..0f950db 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8716,7 +8716,17 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr, cp_lexer_save_tokens (parser->lexer); attrs_location = cp_lexer_peek_token (parser->lexer)->location; + if (c_dialect_objc ()) + /* In obj-c++, seing '[[' might be the either the beginning of + c++11 attributes, or a nested objc-message-expression. So + let's parse the c++11 attributes tentatively. */ + cp_parser_parse_tentatively (parser); std_attrs = cp_parser_std_attribute_spec_seq (parser); + if (c_dialect_objc ()) + { + if (!cp_parser_parse_definitely (parser)) + std_attrs = NULL_TREE; + } /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); @@ -20701,7 +20711,6 @@ cp_parser_std_attribute_spec (cp_parser *parser) && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_OPEN_SQUARE) { cp_lexer_consume_token (parser->lexer); - maybe_warn_cpp0x (CPP0X_ATTRIBUTES); cp_lexer_consume_token (parser->lexer); attributes = cp_parser_std_attribute_list (parser); @@ -20709,6 +20718,10 @@ cp_parser_std_attribute_spec (cp_parser *parser) if (!cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE) || !cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE)) cp_parser_skip_to_end_of_statement (parser); + else + /* Warn about parsing c++11 attribute in non-c++1 mode, only + when we are sure that we have actually parsed them. */ + maybe_warn_cpp0x (CPP0X_ATTRIBUTES); } else {