PR c++/84036 - ICE with variadic capture.
authorJason Merrill <jason@redhat.com>
Fri, 26 Jan 2018 17:10:24 +0000 (12:10 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 26 Jan 2018 17:10:24 +0000 (12:10 -0500)
PR c++/82249
* pt.c (tsubst_pack_expansion): When optimizing a simple
substitution, pull a single pack expansion out of its pack.

From-SVN: r257101

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic8.C [new file with mode: 0644]

index fd3ff71..70b0134 100644 (file)
@@ -1,5 +1,10 @@
 2018-01-26  Jason Merrill  <jason@redhat.com>
 
+       PR c++/84036 - ICE with variadic capture.
+       PR c++/82249
+       * pt.c (tsubst_pack_expansion): When optimizing a simple
+       substitution, pull a single pack expansion out of its pack.
+
        PR c++/82514 - ICE with local class in generic lambda.
        * pt.c (regenerated_lambda_fn_p): Remove.
        (enclosing_instantiation_of): Don't use it.
index de8ad94..6c5d06b 100644 (file)
@@ -11575,6 +11575,12 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
       && TREE_PURPOSE (packs) == pattern)
     {
       tree args = ARGUMENT_PACK_ARGS (TREE_VALUE (packs));
+
+      /* If the argument pack is a single pack expansion, pull it out.  */
+      if (TREE_VEC_LENGTH (args) == 1
+         && pack_expansion_args_count (args))
+       return TREE_VEC_ELT (args, 0);
+
       /* Types need no adjustment, nor does sizeof..., and if we still have
         some pack expansion args we won't do anything yet.  */
       if (TREE_CODE (t) == TYPE_PACK_EXPANSION
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic8.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic8.C
new file mode 100644 (file)
index 0000000..7740d66
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/84036
+// { dg-do compile { target c++14 } }
+
+template < typename T >
+auto f(T){
+    [](auto ... i){
+        [i ...]{};
+    };
+}
+
+int main(){
+    f(0);
+}