From patchwork Thu Sep 19 19:41:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1164813 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-509322-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="QhIrv8Fu"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="RuIunsoh"; 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 46Z6fY5qWRz9sCJ for ; Fri, 20 Sep 2019 05:41:25 +1000 (AEST) 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=OvtkP0/nAVzBDqQO zacw4huqOojRn9FOAa/FaUVqN/KQUwMC7R4EVjdOSYldTNzLZqbL+DWurepy/gbP BT1fOGHrYGCJjzHegQ573egSZzV51I7nnXXdqphOdhVK/qdNne/Xpu1oCUbxPfSi TW2KzCA3sRjjd5GIDMKIp1EGLEI= 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=kWrMTgIbYGYIKPBkEJlAMO XdyIk=; b=QhIrv8FuQ6WFMXXGzx0XrFOVGULT8nMpn5Ygbvbxm8V1NwJIwDKjK+ 03D4tlEPAY1vMp6YrdjF/Zho//Gc/2OQpLukj3vN5lZOjtVIG6hk91EaAZx0OuwK /0Yet9HeAo6tllYqsqTIQ1W7zdCuVTkjevDztvTnKMcFwD6l7VG10= Received: (qmail 50996 invoked by alias); 19 Sep 2019 19:41:19 -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 50987 invoked by uid 89); 19 Sep 2019 19:41:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1898, HX-Spam-Relays-External:sk:us-smtp, HX-HELO:sk:us-smtp, H*RU:sk:us-smtp X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Sep 2019 19:41:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1568922074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jr2Oz+rGcir0/ipB6UNQ7Cq+zVDfPMBMhtLptVP+GMs=; b=RuIunsohah/biMUO+mtyLchJteMrPDFFb5PxRl0+SmCFJIZLkgkqtgmvjVgUJDZjMWABvs wlxReBNwdMoeu7BjBfoxFxul5mORVlKU0zS/r+m09YX+gSW/JLWInmWo5GKQ+XRGl5VFDy sAWZ9Bf8+OoT1FeD2ZEVdxOkFLcept0= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-206-xTadujhCMVaXEUcZN4C1Mg-1; Thu, 19 Sep 2019 15:41:12 -0400 Received: by mail-qt1-f200.google.com with SMTP id j5so4530071qtn.10 for ; Thu, 19 Sep 2019 12:41:12 -0700 (PDT) Received: from localhost.localdomain (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 t126sm5573614qkh.119.2019.09.19.12.41.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 12:41:10 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Handle [[likely]] on compound-statement. Date: Thu, 19 Sep 2019 15:41:09 -0400 Message-Id: <20190919194109.19299-1-jason@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-IsSubscribed: yes I overlooked this case when adding [[likely]] handling to cp_parser_statement. Tested x86_64-pc-linux-gnu, applying to trunk. * parser.c (cp_parser_statement): Handle [[likely]] on compound-statement. --- gcc/cp/parser.c | 5 ++++- gcc/testsuite/g++.dg/cpp2a/attr-likely5.C | 9 +++++++++ gcc/cp/ChangeLog | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/attr-likely5.C base-commit: aae9c42b1657673a0df0829380edc7c6b7e486b1 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 165039ef07c..da0ffacc218 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -11297,7 +11297,10 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr, } /* Anything that starts with a `{' must be a compound-statement. */ else if (token->type == CPP_OPEN_BRACE) - statement = cp_parser_compound_statement (parser, NULL, BCS_NORMAL, false); + { + std_attrs = process_stmt_hotness_attribute (std_attrs, attrs_loc); + statement = cp_parser_compound_statement (parser, NULL, BCS_NORMAL, false); + } /* CPP_PRAGMA is a #pragma inside a function body, which constitutes a statement all its own. */ else if (token->type == CPP_PRAGMA) diff --git a/gcc/testsuite/g++.dg/cpp2a/attr-likely5.C b/gcc/testsuite/g++.dg/cpp2a/attr-likely5.C new file mode 100644 index 00000000000..166214835d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/attr-likely5.C @@ -0,0 +1,9 @@ +// { dg-do compile { target c++11 } } + +void f(int i) +{ + if (i) [[likely]] + { + ++i; + } +} diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index de1677f6142..3015d6806d0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-09-17 Jason Merrill + + * parser.c (cp_parser_statement): Handle [[likely]] on + compound-statement. + 2019-09-19 Jason Merrill Revert: