Thinko in the tsubst_attributes logic.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 9460ce06baf4d47d44aa7111f991bb50e6644f67
Author: Jason Merrill <ja...@redhat.com>
Date:   Thu Jul 14 10:56:25 2016 -0400

        PR c++/71513 - alignas on member enum in template
    
        * pt.c (tsubst_attributes): Fix loop logic.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index de70fb2..1fbf546 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 0000000..a209250
--- /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<al,char>::E) == al);

Reply via email to