public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [C++ PATCH] Handle [[likely]] on compound-statement.
Date: Thu, 19 Sep 2019 19:41:00 -0000	[thread overview]
Message-ID: <20190919194109.19299-1-jason@redhat.com> (raw)

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

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  <jason@redhat.com>
+
+	* parser.c (cp_parser_statement): Handle [[likely]] on
+	compound-statement.
+
 2019-09-19  Jason Merrill  <jason@redhat.com>
 
 	Revert:

base-commit: aae9c42b1657673a0df0829380edc7c6b7e486b1
-- 
2.21.0

                 reply	other threads:[~2019-09-19 19:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190919194109.19299-1-jason@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).