PR c++/72415 - member template with fold-expression constraint
authorJason Merrill <jason@redhat.com>
Thu, 4 Aug 2016 16:06:22 +0000 (12:06 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 4 Aug 2016 16:06:22 +0000 (12:06 -0400)
* pt.c (tsubst_pack_expansion): Pull a single pack expansion out
of the TREE_VEC.

From-SVN: r239138

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

index e7854f7505e2e3cac61c66910aa4496c9eb49410..573ece8bbad7fdbee6fdaa0b15cd600ab6d1980d 100644 (file)
@@ -1,5 +1,9 @@
 2016-08-04  Jason Merrill  <jason@redhat.com>
 
+       PR c++/72415
+       * pt.c (tsubst_pack_expansion): Pull a single pack expansion out
+       of the TREE_VEC.
+
        * cp-tree.h (TYPE_UNNAMED_P): Rename from TYPE_ANONYMOUS_P.
        (TYPE_WAS_UNNAMED): Rename from TYPE_WAS_ANONYMOUS.
        * class.c, decl.c, decl2.c, error.c, lambda.c, mangle.c,
index bf729ea3107f7b7457c7fc2e843ac67e5e3acbe1..60c87e001c05c8a7e2438994e6d32568b1de83ab 100644 (file)
@@ -11160,6 +11160,12 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
       local_specializations = saved_local_specializations;
     }
   
+  /* If the dependent pack arguments were such that we end up with only a
+     single pack expansion again, there's no need to keep it in a TREE_VEC.  */
+  if (len == 1 && TREE_CODE (result) == TREE_VEC
+      && PACK_EXPANSION_P (TREE_VEC_ELT (result, 0)))
+    return TREE_VEC_ELT (result, 0);
+
   return result;
 }
 
diff --git a/gcc/testsuite/g++.dg/concepts/memfun2.C b/gcc/testsuite/g++.dg/concepts/memfun2.C
new file mode 100644 (file)
index 0000000..c186a18
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/72415
+// { dg-options "-std=c++1z -fconcepts" }
+
+template<int... Indices>
+struct indices {};
+
+template<typename Dummy>
+struct foo_type {
+    template<int... Indices>
+    static void impl(indices<Indices...>)
+        requires (... && (Indices, true));
+
+    static auto caller()
+    { return impl(indices<0, 1, 2> {}); }
+};
+
+int main()
+{
+    // internal compiler error: in satisfy_predicate_constraint, at cp/constraint.cc:2013
+    foo_type<void>::caller();
+}