diff mbox series

C++ PATCH for c++/84839, ICE with decltype of parameter pack

Message ID CADzB+2=NpqVMtv8TikQC9vuaYjbb3i8Nh2r0qhJAYZDKZ602+A@mail.gmail.com
State New
Headers show
Series C++ PATCH for c++/84839, ICE with decltype of parameter pack | expand

Commit Message

Jason Merrill March 13, 2018, 6:55 p.m. UTC
The comment says that the parameter pack is being used in an
unevaluated context, but at the point where we're substituting the
pack, we aren't necessarily actually in that unevaluated context, so
let's set the flag here.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox series

Patch

commit 0999f196019abd26f2409f351a443b45eafc234b
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 13 14:08:17 2018 -0400

            PR c++/84839 - ICE with decltype of parameter pack.
    
            * pt.c (tsubst_pack_expansion): Set cp_unevaluated_operand while
            instantiating dummy parms.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4640ca08ce0..fdc1c9a7a75 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11717,7 +11717,9 @@  tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
 	    {
 	      /* This parameter pack was used in an unevaluated context.  Just
 		 make a dummy decl, since it's only used for its type.  */
+	      ++cp_unevaluated_operand;
 	      arg_pack = tsubst_decl (parm_pack, args, complain);
+	      --cp_unevaluated_operand;
 	      if (arg_pack && DECL_PACK_P (arg_pack))
 		/* Partial instantiation of the parm_pack, we can't build
 		   up an argument pack yet.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-nested2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-nested2.C
new file mode 100644
index 00000000000..ce18f99ea50
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-nested2.C
@@ -0,0 +1,9 @@ 
+// PR c++/84839
+// { dg-do compile { target c++11 } }
+
+template<typename... T>
+struct S {
+    using fptr = void(*)(T... x, decltype(x)... y);
+};
+
+using F = S<int>::fptr;