From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84899 invoked by alias); 5 Dec 2018 21:47:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 84702 invoked by uid 89); 5 Dec 2018 21:47:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=observes X-HELO: mail-qt1-f194.google.com Received: from mail-qt1-f194.google.com (HELO mail-qt1-f194.google.com) (209.85.160.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Dec 2018 21:47:41 +0000 Received: by mail-qt1-f194.google.com with SMTP id y20so24082323qtm.13 for ; Wed, 05 Dec 2018 13:47:41 -0800 (PST) Return-Path: Received: from [192.168.1.149] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id 24sm13486904qkx.77.2018.12.05.13.47.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 13:47:38 -0800 (PST) Subject: Re: [PATCH 1/2] asm qualifiers (PR55681) To: Segher Boessenkool , gcc-patches@gcc.gnu.org Cc: jakub@redhat.com, Joseph Myers , nathan@acm.org, polacek@redhat.com References: <74db3dde365a2a30fc5d4779ef67278a2b29ca1a.1543766396.git.segher@kernel.crashing.org> From: Jason Merrill Message-ID: <0f5fe39e-4061-1b0b-bb5c-3676f395bff6@redhat.com> Date: Wed, 05 Dec 2018 21:47:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <74db3dde365a2a30fc5d4779ef67278a2b29ca1a.1543766396.git.segher@kernel.crashing.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg00315.txt.bz2 On 12/2/18 11:38 AM, Segher Boessenkool wrote: > PR55681 observes that currently only one qualifier is allowed for > inline asm, so that e.g. "volatile asm" is allowed, "const asm" is also > okay (with a warning), but "const volatile asm" gives an error. Also > "goto" has to be last. > > This patch changes things so that only "asm-qualifiers" are allowed, > that is "volatile" and "goto", in any combination, in any order, but > without repetitions. > > > 2018-12-02 Segher Boessenkool > > PR inline-asm/55681 > * doc/extend.texi (Basic Asm): Update grammar. > (Extended Asm): Update grammar. > > gcc/c/ > PR inline-asm/55681 > * c-parser.c (c_parser_for_statement): Update grammar. Allow any > combination of volatile and goto, in any order, without repetitions. > > gcc/cp/ > PR inline-asm/55681 > * parser.c (cp_parser_using_directive): Update grammar. Allow any > combination of volatile and goto, in any order, without repetitions. You don't actually change cp_parser_using_directive, despite what diff says: you're changing cp_parser_asm_definition. > + for (bool done = false; !done ; ) > + switch (cp_lexer_peek_token (parser->lexer)->keyword) > + { > + case RID_VOLATILE: > + if (!volatile_p) > + { > + /* Remember that we saw the `volatile' keyword. */ > + volatile_p = true; > + /* Consume the token. */ > + cp_lexer_consume_token (parser->lexer); > + } > + else > + done = true; > + break; > + case RID_GOTO: > + if (!goto_p && parser->in_function_body) > + { > + /* Remember that we saw the `goto' keyword. */ > + goto_p = true; > + /* Consume the token. */ > + cp_lexer_consume_token (parser->lexer); > + } > + else > + done = true; > + break; > + default: > + done = true; > + } An arguably simpler alternative to using the 'done' variable would be to 'break' out of the loop after the switch, and have the consume_token cases explicitly 'continue'. We also might remember the old tokens and give a more helpful error message in the case of duplicate keywords. But I won't insist on either of these, the C++ changes are OK as-is. Jason