C++ PATCH for c++/86063, ICE with attribute with pack expansion
Marek Polacek
polacek@redhat.com
Wed Jun 6 21:18:00 GMT 2018
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" }
+};
More information about the Gcc-patches
mailing list