diff options
author | Jason Merrill <jason@redhat.com> | 2020-03-14 17:10:39 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-03-14 17:13:25 -0400 |
commit | c393c99d3dc8329dc1a36011e70faa9700185051 (patch) | |
tree | 69fa9d705775291835c3d9c8a1968d3b8fbeeaeb | |
parent | 6e5084b44016113f2c6950be8782d8c84397ef4b (diff) | |
download | gcc-c393c99d3dc8329dc1a36011e70faa9700185051.zip gcc-c393c99d3dc8329dc1a36011e70faa9700185051.tar.gz gcc-c393c99d3dc8329dc1a36011e70faa9700185051.tar.bz2 |
c++: Fix CTAD with multiple-arg ctor template [93248].
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.
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/class-deduction71.C | 6 |
3 files changed, 16 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 79434c9..b4fa150 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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-14 Jakub Jelinek <jakub@redhat.com> * logic.cc (formula::formula): Change "a an" to "an" in a comment. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 789ccdb..0f3c2ad 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -28071,10 +28071,13 @@ build_deduction_guide (tree type, tree ctor, tree outer_args, tsubst_flags_t com 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 index 0000000..2fc71de --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction71.C @@ -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}); |