From patchwork Thu Dec 27 14:59:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 1018918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-493131-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Ryi1YJDC"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43QY1N4WStz9s7h for ; Fri, 28 Dec 2018 02:00:40 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=MXiLuUPh8Yw1BPIrJwx +diOhgfDz87UWHssbbthJxzLM0c8P9Uz+KmtqYRoQfQ+UTgj7kWnK5mHvDvShbA5 C1qrShkUy5cAXSmK91IfGZGrgr6f6tNUUHfjF6b7Hc5kjlDCAbZ20/3yTLsJYYZl /MEZsWCBGDHL+uHccy5uC5z4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; s=default; bh=Sf89IKQb6zbr8Bgyu5sK9tafh wE=; b=Ryi1YJDC9cBKd95PaNXLXdX6Uz1qtqjH7bZTn+N4ZaUWAroPapOVu57MD /3Yd/OQ7qvyl43DigiaAr8N894rKOD1tynDl8grJZedytE+NWgOtw3vx4GW/P/HH QsOD1C+oVu1b5j7Zt3TLFV7hT5cJn6n8lFWzFIoCJ/+7VatFTU= Received: (qmail 126989 invoked by alias); 27 Dec 2018 14:59:43 -0000 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 Received: (qmail 126773 invoked by uid 89); 27 Dec 2018 14:59:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=jason X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Dec 2018 14:59:38 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id EE591124068C; Thu, 27 Dec 2018 14:59:36 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [PATCH 4/8] c/c++, asm: Write the asm-qualifier loop without "done" boolean Date: Thu, 27 Dec 2018 14:59:09 +0000 Message-Id: <5bbbd04162b8546d9c72da11cf33e6e61d1128d7.1545922222.git.segher@kernel.crashing.org> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes As suggested by Jason. Segher 2018-12-10 Segher Boessenkool c/ * c-parser.c (c_parser_asm_statement): Rewrite the loop to work without "done" boolean variable. cp/ * parser.c (cp_parser_asm_definition): Rewrite the loop to work without "done" boolean variable. --- gcc/c/c-parser.c | 65 +++++++++++++++++++++++++-------------------------- gcc/cp/parser.c | 71 +++++++++++++++++++++++++------------------------------- 2 files changed, 62 insertions(+), 74 deletions(-) diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index e45f70b..b632f68 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -6304,40 +6304,37 @@ c_parser_asm_statement (c_parser *parser) is_volatile = false; is_inline = false; is_goto = false; - for (bool done = false; !done; ) - switch (c_parser_peek_token (parser)->keyword) - { - case RID_VOLATILE: - if (!is_volatile) - { - is_volatile = true; - quals = c_parser_peek_token (parser)->value; - c_parser_consume_token (parser); - } - else - done = true; - break; - case RID_INLINE: - if (!is_inline) - { - is_inline = true; - c_parser_consume_token (parser); - } - else - done = true; - break; - case RID_GOTO: - if (!is_goto) - { - is_goto = true; - c_parser_consume_token (parser); - } - else - done = true; - break; - default: - done = true; - } + for (;;) + { + switch (c_parser_peek_token (parser)->keyword) + { + case RID_VOLATILE: + if (is_volatile) + break; + is_volatile = true; + quals = c_parser_peek_token (parser)->value; + c_parser_consume_token (parser); + continue; + + case RID_INLINE: + if (is_inline) + break; + is_inline = true; + c_parser_consume_token (parser); + continue; + + case RID_GOTO: + if (is_goto) + break; + is_goto = true; + c_parser_consume_token (parser); + continue; + + default: + break; + } + break; + } /* ??? Follow the C++ parser rather than using the lex_untranslated_string kludge. */ diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3fd9a02..7660565 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -19124,47 +19124,38 @@ cp_parser_asm_definition (cp_parser* parser) cp_function_chain->invalid_constexpr = true; } - /* See if the next token is `volatile'. */ + /* Handle the asm-qualifier-list. */ if (cp_parser_allow_gnu_extensions_p (parser)) - 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_INLINE: - if (!inline_p && parser->in_function_body) - { - /* Remember that we saw the `inline' keyword. */ - inline_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; - } + for (;;) + { + switch (cp_lexer_peek_token (parser->lexer)->keyword) + { + case RID_VOLATILE: + if (volatile_p) + break; + volatile_p = true; + cp_lexer_consume_token (parser->lexer); + continue; + + case RID_INLINE: + if (inline_p || !parser->in_function_body) + break; + inline_p = true; + cp_lexer_consume_token (parser->lexer); + continue; + + case RID_GOTO: + if (goto_p || !parser->in_function_body) + break; + goto_p = true; + cp_lexer_consume_token (parser->lexer); + continue; + + default: + break; + } + break; + } /* Look for the opening `('. */ if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))