PR c++/71513 - alignas on member enum in template
authorJason Merrill <jason@redhat.com>
Fri, 15 Jul 2016 18:38:40 +0000 (14:38 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 15 Jul 2016 18:38:40 +0000 (14:38 -0400)
* pt.c (tsubst_attributes): Fix loop logic.

From-SVN: r238392

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/alignas7.C [new file with mode: 0644]

index 14bcf8e9e54aede0d712b3a2132c9f5763ca695e..84106b82a4332affd41a6aeab346e6cf5bc247c0 100644 (file)
@@ -1,5 +1,8 @@
 2016-07-15  Jason Merrill  <jason@redhat.com>
 
+       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.
index de70fb2f1c6104595e986dd1ab1cb2f01f07bd2e..1fbf546aaf235675e273c07a9dcdadf0c52d9d2e 100644 (file)
@@ -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 (file)
index 0000000..a209250
--- /dev/null
@@ -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);