From: Marek Polacek <polacek@redhat.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>
Subject: C++ PATCH for c++/86063, ICE with attribute with pack expansion
Date: Wed, 06 Jun 2018 21:18:00 -0000 [thread overview]
Message-ID: <20180606211835.GC28085@redhat.com> (raw)
We crash on this testcase containing a bogus attribute, because
cp_check_const_attributes accessed TREE_VALUE of a tree that happened to be
expr_pack_expansion. Since here we're merely trying to evaluate constexpr
arguments, I thought we could skip such bogus arguments.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2018-06-06 Marek Polacek <polacek@redhat.com>
PR c++/86063
* decl2.c (cp_check_const_attributes): Skip trees that are not
TREE_LISTs.
* g++.dg/cpp0x/gen-attrs-65.C: New test.
diff --git gcc/cp/decl2.c gcc/cp/decl2.c
index 2cef9c750ed..35d8e423397 100644
--- gcc/cp/decl2.c
+++ gcc/cp/decl2.c
@@ -1386,7 +1386,8 @@ cp_check_const_attributes (tree attributes)
for (attr = attributes; attr; attr = TREE_CHAIN (attr))
{
tree arg;
- for (arg = TREE_VALUE (attr); arg; arg = TREE_CHAIN (arg))
+ for (arg = TREE_VALUE (attr); arg && TREE_CODE (arg) == TREE_LIST;
+ arg = TREE_CHAIN (arg))
{
tree expr = TREE_VALUE (arg);
if (EXPR_P (expr))
diff --git gcc/testsuite/g++.dg/cpp0x/gen-attrs-65.C gcc/testsuite/g++.dg/cpp0x/gen-attrs-65.C
index e69de29bb2d..1d2b2f04e7a 100644
--- gcc/testsuite/g++.dg/cpp0x/gen-attrs-65.C
+++ gcc/testsuite/g++.dg/cpp0x/gen-attrs-65.C
@@ -0,0 +1,7 @@
+// PR c++/86063
+// { dg-do compile { target c++11 } }
+
+template <class... T>
+struct S {
+ [[foobar(alignof(T))...]] char t; // { dg-warning "attribute directive ignored" }
+};
next reply other threads:[~2018-06-06 21:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 21:18 Marek Polacek [this message]
2018-06-11 19:00 ` Jason Merrill
2018-06-14 16:51 ` Marek Polacek
2018-06-14 16:59 ` Jason Merrill
2018-06-14 19:40 ` Marek Polacek
2018-06-14 20:46 ` Jason Merrill
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=20180606211835.GC28085@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/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).