From: Jason Merrill Date: Fri, 15 Jul 2016 18:38:40 +0000 (-0400) Subject: PR c++/71513 - alignas on member enum in template X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1019d191806b61fb07a4197bf769b4508a572d9c;p=gcc.git PR c++/71513 - alignas on member enum in template * pt.c (tsubst_attributes): Fix loop logic. From-SVN: r238392 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 14bcf8e9e54..84106b82a43 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2016-07-15 Jason Merrill + PR c++/71513 + * pt.c (tsubst_attributes): Fix loop logic. + PR c++/71604 PR c++/54430 * parser.c (cp_parser_range_for): Modify IDENTIFIER_BINDING directly. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index de70fb2f1c6..1fbf546aaf2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9713,20 +9713,23 @@ tsubst_attributes (tree attributes, tree args, } if (last_dep) - for (tree *p = &attributes; *p; p = &TREE_CHAIN (*p)) + for (tree *p = &attributes; *p; ) { tree t = *p; if (ATTR_IS_DEPENDENT (t)) { tree subst = tsubst_attribute (t, NULL, args, complain, in_decl); - if (subst == t) - continue; - *p = subst; - do - p = &TREE_CHAIN (*p); - while (*p); - *p = TREE_CHAIN (t); + if (subst != t) + { + *p = subst; + do + p = &TREE_CHAIN (*p); + while (*p); + *p = TREE_CHAIN (t); + continue; + } } + p = &TREE_CHAIN (*p); } return attributes; diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas7.C b/gcc/testsuite/g++.dg/cpp0x/alignas7.C new file mode 100644 index 00000000000..a209250af9b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alignas7.C @@ -0,0 +1,13 @@ +// PR c++/71513 +// { dg-do compile { target c++11 } } + +template < int N, typename T > +struct A +{ + enum alignas (N) E : T; +}; + +#define SA(X) static_assert((X), #X) + +constexpr int al = alignof(double); +SA(alignof(A::E) == al);