From 08735f538cd94d5be5fa1b8ee79bfabc7f530a8a Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 26 Feb 2018 20:06:40 +0000 Subject: [PATCH] re PR c++/84540 (ICE with alignas in variadic template) /cp 2018-02-26 Paolo Carlini PR c++/84540 * pt.c (tsubst_attributes): Handle correctly tsubst_attribute returning NULL_TREE. (apply_late_template_attributes): Likewise. /testsuite 2018-02-26 Paolo Carlini PR c++/84540 * g++.dg/cpp0x/alignas14.C: New. * g++.dg/cpp0x/alignas15.C: Likewise. From-SVN: r258012 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/pt.c | 6 ++---- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/cpp0x/alignas14.C | 6 ++++++ gcc/testsuite/g++.dg/cpp0x/alignas15.C | 6 ++++++ 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas14.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas15.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 94f684b041b..d75f1a834e6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-02-26 Paolo Carlini + + PR c++/84540 + * pt.c (tsubst_attributes): Handle correctly tsubst_attribute + returning NULL_TREE. + (apply_late_template_attributes): Likewise. + 2018-02-26 Jakub Jelinek PR c++/84557 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9cf96e9fbe4..42fd872d6c0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10245,9 +10245,8 @@ tsubst_attributes (tree attributes, tree args, if (subst != t) { *p = subst; - do + while (*p) p = &TREE_CHAIN (*p); - while (*p); *p = TREE_CHAIN (t); continue; } @@ -10314,9 +10313,8 @@ apply_late_template_attributes (tree *decl_p, tree attributes, int attr_flags, *p = TREE_CHAIN (t); TREE_CHAIN (t) = NULL_TREE; *q = tsubst_attribute (t, decl_p, args, complain, in_decl); - do + while (*q) q = &TREE_CHAIN (*q); - while (*q); } else p = &TREE_CHAIN (t); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9ebfd3edd93..f050086b8bb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-02-26 Paolo Carlini + + PR c++/84540 + * g++.dg/cpp0x/alignas14.C: New. + * g++.dg/cpp0x/alignas15.C: Likewise. + 2018-02-26 Jakub Jelinek PR c++/84557 diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas14.C b/gcc/testsuite/g++.dg/cpp0x/alignas14.C new file mode 100644 index 00000000000..498e9754d8c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alignas14.C @@ -0,0 +1,6 @@ +// PR c++/84540 +// { dg-do compile { target c++11 } } + +template struct alignas(alignof(T)...) A {}; + +A<> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas15.C b/gcc/testsuite/g++.dg/cpp0x/alignas15.C new file mode 100644 index 00000000000..7244dce5bc1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alignas15.C @@ -0,0 +1,6 @@ +// PR c++/84540 +// { dg-do compile { target c++11 } } + +template struct A { enum alignas(alignof(T)...) E {}; }; + +A<> a; -- 2.30.2