Re: [C++ Patch] PR 84540 ("[6/7/8 Regression] ICE with alignas in variadic template")

2018-02-26 Thread Jason Merrill
OK.

On Mon, Feb 26, 2018 at 11:56 AM, Paolo Carlini
 wrote:
> Hi,
>
> this regression is an ICE on valid, and seems rather easy to analyze: both
> apply_late_template_attributes and tsubst_attributes don't appear to cope
> correctly with tsubst_attribute returning NULL_TREE. That, in turn, seems
> normal for an empty pack - as in the testcases - given the structure of the
> last part of the latter, handling PACK_EXPANSION_P (val). I'm finishing
> testing on x86_64-linux (in libstdc++-v3, so far so good).
>
> Thanks, Paolo.
>
> ///
>


[C++ Patch] PR 84540 ("[6/7/8 Regression] ICE with alignas in variadic template")

2018-02-26 Thread Paolo Carlini

Hi,

this regression is an ICE on valid, and seems rather easy to analyze: 
both apply_late_template_attributes and tsubst_attributes don't appear 
to cope correctly with tsubst_attribute returning NULL_TREE. That, in 
turn, seems normal for an empty pack - as in the testcases - given the 
structure of the last part of the latter, handling PACK_EXPANSION_P 
(val). I'm finishing testing on x86_64-linux (in libstdc++-v3, so far so 
good).


Thanks, Paolo.

///

/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.
Index: cp/pt.c
===
--- cp/pt.c (revision 257989)
+++ cp/pt.c (working copy)
@@ -10245,9 +10245,8 @@ tsubst_attributes (tree attributes, tree args,
if (subst != t)
  {
*p = subst;
-   do
+   while (*p)
  p = _CHAIN (*p);
-   while (*p);
*p = TREE_CHAIN (t);
continue;
  }
@@ -10314,9 +10313,8 @@ apply_late_template_attributes (tree *decl_p, tree
  *p = TREE_CHAIN (t);
  TREE_CHAIN (t) = NULL_TREE;
  *q = tsubst_attribute (t, decl_p, args, complain, in_decl);
- do
+ while (*q)
q = _CHAIN (*q);
- while (*q);
}
  else
p = _CHAIN (t);
Index: testsuite/g++.dg/cpp0x/alignas14.C
===
--- testsuite/g++.dg/cpp0x/alignas14.C  (nonexistent)
+++ testsuite/g++.dg/cpp0x/alignas14.C  (working copy)
@@ -0,0 +1,6 @@
+// PR c++/84540
+// { dg-do compile { target c++11 } }
+
+template struct alignas(alignof(T)...) A {};
+
+A<> a;
Index: testsuite/g++.dg/cpp0x/alignas15.C
===
--- testsuite/g++.dg/cpp0x/alignas15.C  (nonexistent)
+++ testsuite/g++.dg/cpp0x/alignas15.C  (working copy)
@@ -0,0 +1,6 @@
+// PR c++/84540
+// { dg-do compile { target c++11 } }
+
+template struct A { enum alignas(alignof(T)...) E {}; };
+
+A<> a;