]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Fix CTAD with multiple-arg ctor template [93248].
authorJason Merrill <jason@redhat.com>
Sat, 14 Mar 2020 21:10:39 +0000 (17:10 -0400)
committerJason Merrill <jason@redhat.com>
Sun, 15 Mar 2020 09:47:28 +0000 (05:47 -0400)
When cp_unevaluated_operand is set, tsubst_decl thinks that if it sees a
PARM_DECL that isn't already in local_specializations, we're in a decltype
in a trailing return type or some such, and so we only want a substitution
for a single PARM_DECL.  In this case, we want the whole chain, so make sure
cp_unevaluated_operand is cleared.

gcc/cp/ChangeLog
2020-03-14  Jason Merrill  <jason@redhat.com>

PR c++/93248
* pt.c (build_deduction_guide): Clear cp_unevaluated_operand for
substituting DECL_ARGUMENTS.

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1z/class-deduction71.C [new file with mode: 0644]

index 6441d647a546ee0094ceee2b8607a608c13bf6e2..0bc9e12014d69d74c99ce24d14316dad85bd20a6 100644 (file)
@@ -1,3 +1,9 @@
+2020-03-14  Jason Merrill  <jason@redhat.com>
+
+       PR c++/93248
+       * pt.c (build_deduction_guide): Clear cp_unevaluated_operand for
+       substituting DECL_ARGUMENTS.
+
 2020-03-12  Release Manager
 
        * GCC 9.3.0 released.
index 4787747b6ff2e747c1844616d5f654cccf5722e2..a12da5ef86663638e0c69963d6471ac0f5f2e972 100644 (file)
@@ -27376,10 +27376,13 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain)
                                     complain, ctor);
          if (fparms == error_mark_node)
            ok = false;
-         fargs = tsubst (fargs, tsubst_args, complain, ctor);
          if (ci)
            ci = tsubst_constraint_info (ci, tsubst_args, complain, ctor);
 
+         /* Parms are to have DECL_CHAIN tsubsted, which would be skipped if
+            cp_unevaluated_operand.  */
+         cp_evaluated ev;
+         fargs = tsubst (fargs, tsubst_args, complain, ctor);
          current_template_parms = save_parms;
        }
 
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction71.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction71.C
new file mode 100644 (file)
index 0000000..2fc71de
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/93248
+// { dg-do compile { target c++17 } }
+
+template <typename T> struct S
+{ template <typename V> S (T, V, long = 0); };
+using U = decltype(S{0, 4u});