re PR c++/84540 (ICE with alignas in variadic template)
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 26 Feb 2018 20:06:40 +0000 (20:06 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 26 Feb 2018 20:06:40 +0000 (20:06 +0000)
/cp
2018-02-26  Paolo Carlini  <paolo.carlini@oracle.com>

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  <paolo.carlini@oracle.com>

PR c++/84540
* g++.dg/cpp0x/alignas14.C: New.
* g++.dg/cpp0x/alignas15.C: Likewise.

From-SVN: r258012

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

index 94f684b041b07dfa280ae417180c378dc16f4294..d75f1a834e6c3c52a665953e0caa2b5eac576124 100644 (file)
@@ -1,3 +1,10 @@
+2018-02-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84540
+       * pt.c (tsubst_attributes): Handle correctly tsubst_attribute
+       returning NULL_TREE.
+       (apply_late_template_attributes): Likewise.
+
 2018-02-26  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/84557
index 9cf96e9fbe4bf0a34b3a79d5c5439f171f3bc0b5..42fd872d6c0f6a3e6ed865d431f3a1254578e0c0 100644 (file)
@@ -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);
index 9ebfd3edd93d461031df338013d0de8f6206070f..f050086b8bb07fd6959036ab37e39c19128be613 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84540
+       * g++.dg/cpp0x/alignas14.C: New.
+       * g++.dg/cpp0x/alignas15.C: Likewise.
+
 2018-02-26  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..498e975
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/84540
+// { dg-do compile { target c++11 } }
+
+template<typename... T> 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 (file)
index 0000000..7244dce
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/84540
+// { dg-do compile { target c++11 } }
+
+template<typename... T> struct A { enum alignas(alignof(T)...) E {}; };
+
+A<> a;