From patchwork Fri Oct 26 17:37:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 194548 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 38DF32C0091 for ; Sat, 27 Oct 2012 04:37:41 +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=1351877861; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Cc:Subject:Date: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=wSVpytTpcyAmNNZghLSCt7uGPXs=; b=sFGRzRiM8mVNqaI uefu4PDNb3su5ZvzjeeZJkcrBd3SjAnj1aM5l97dyuiA0dsJikCTbkhR/aI7UV6L wQTwArmzotssqEAg37e1O9eNe26HV0cQ7Lys3WMny5KkUJ9QvgJCsTmSz+QLq7Vz iy2hm/Ew88S41Fg/3gW1uMJBpPds= 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:X-URL:Date: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=a/RgYbzkgibPS56fTi7VLll6dm3rMARcNACgMLc3shPn28P6Xv3nlY2R0XGAY6 KzF0tv8WFooFOteu82f82PiN7M2vWN03IbVtHCmZDinPZRCxdOfJqYu59y7Tfr7K xUh+BfAUJhLY9a/4ml1Tt4DE4ghBA3LEX/P3XgNMPo34Q=; Received: (qmail 13245 invoked by alias); 26 Oct 2012 17:37:37 -0000 Received: (qmail 13221 invoked by uid 22791); 26 Oct 2012 17:37:36 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_CX 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; Fri, 26 Oct 2012 17:37:32 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9QHbWXL016122 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Oct 2012 13:37:32 -0400 Received: from localhost (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9QHbS24012098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 26 Oct 2012 13:37:31 -0400 Received: by localhost (Postfix, from userid 1000) id 1D6782C0104; Fri, 26 Oct 2012 19:37:27 +0200 (CEST) From: Dodji Seketeli To: GCC Patches Cc: Jason Merrill Subject: [PATCH] PR c++/54955 - Fail to parse alignas expr at the beginning of a declaration X-URL: http://www.redhat.com Date: Fri, 26 Oct 2012 19:37:26 +0200 Message-ID: <87wqyddtih.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (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, In this PR, G++ embarrassingly fails to parse the simple alignas expression below: alignas(double) int f; even though the simple-declaration production in Clause 7 suggests otherwise. Fixed thus and tested on x86_64-unknown-linux-gnu against trunk. gcc/cp PR c++/54955 * parser.c (cp_next_tokens_can_be_std_attribute_p): Recognize the 'alignas' keyword as the beginning of a c++11 attribute specifier. Update the comment of the function. gcc/testsuite/ PR c++/54955 * g++.dg/cpp0x/gen-attrs-48-2.C: New test. --- gcc/cp/parser.c | 8 ++++++-- gcc/testsuite/g++.dg/cpp0x/gen-attrs-48-2.C | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/gen-attrs-48-2.C diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 9403563..50c1854 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -20324,12 +20324,16 @@ cp_next_tokens_can_be_gnu_attribute_p (cp_parser *parser) } /* Return TRUE iff the next tokens in the stream are possibly the - beginning of a standard C++-11 attribute. */ + beginning of a standard C++-11 attribute specifier. */ static bool cp_next_tokens_can_be_std_attribute_p (cp_parser *parser) { - return cp_nth_tokens_can_be_std_attribute_p (parser, 1); + cp_token *token = cp_lexer_peek_token (parser->lexer); + + return (cxx_dialect >= cxx0x + (token->type == CPP_KEYWORD && token->keyword == RID_ALIGNAS) + || cp_nth_tokens_can_be_std_attribute_p (parser, 1)); } /* Return TRUE iff the next Nth tokens in the stream are possibly the diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-48-2.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-48-2.C new file mode 100644 index 0000000..3cc5897 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-48-2.C @@ -0,0 +1,4 @@ +// Origin: PR c++/54955 +// { dg-do compile { target c++11 } } + +alignas(double) int f;