* [PATCH] c++: alias CTAD inside decltype [PR101233]
@ 2021-07-15 16:37 Patrick Palka
2021-07-16 17:16 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2021-07-15 16:37 UTC (permalink / raw)
To: gcc-patches
This is the alias CTAD version of the CTAD bug PR93248, and the fix is
the same: clear cp_unevaluated_operand so that the entire chain of
DECL_ARGUMENTS gets substituted.
Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
trunk/11?
PR c++/101233
gcc/cp/ChangeLog:
* pt.c (alias_ctad_tweaks): Clear cp_unevaluated_operand for
substituting DECL_ARGUMENTS.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/class-deduction-alias10.C: New test.
---
gcc/cp/pt.c | 12 +++++++++---
gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C | 10 ++++++++++
2 files changed, 19 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c7bf7d412ca..bc0a0936579 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -29097,9 +29097,15 @@ alias_ctad_tweaks (tree tmpl, tree uguides)
/* Substitute the deduced arguments plus the rewritten template
parameters into f to get g. This covers the type, copyness,
guideness, and explicit-specifier. */
- tree g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain);
- if (g == error_mark_node)
- continue;
+ tree g;
+ {
+ /* Parms are to have DECL_CHAIN tsubsted, which would be skipped
+ if cp_unevaluated_operand. */
+ cp_evaluated ev;
+ g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain);
+ if (g == error_mark_node)
+ continue;
+ }
DECL_USE_TEMPLATE (g) = 0;
fprime = build_template_decl (g, gtparms, false);
DECL_TEMPLATE_RESULT (fprime) = g;
diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C
new file mode 100644
index 00000000000..a473fff5dc7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C
@@ -0,0 +1,10 @@
+// PR c++/101233
+// { dg-do compile { target c++20 } }
+
+template<class T, class U>
+struct A { A(T, U); };
+
+template<class T, class U>
+using B = A<U, T>;
+
+using type = decltype(B{0, 0});
--
2.32.0.264.g75ae10bc75
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: alias CTAD inside decltype [PR101233]
2021-07-15 16:37 [PATCH] c++: alias CTAD inside decltype [PR101233] Patrick Palka
@ 2021-07-16 17:16 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2021-07-16 17:16 UTC (permalink / raw)
To: Patrick Palka, gcc-patches
On 7/15/21 12:37 PM, Patrick Palka wrote:
> This is the alias CTAD version of the CTAD bug PR93248, and the fix is
> the same: clear cp_unevaluated_operand so that the entire chain of
> DECL_ARGUMENTS gets substituted.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk/11?
OK.
> PR c++/101233
>
> gcc/cp/ChangeLog:
>
> * pt.c (alias_ctad_tweaks): Clear cp_unevaluated_operand for
> substituting DECL_ARGUMENTS.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/cpp2a/class-deduction-alias10.C: New test.
> ---
> gcc/cp/pt.c | 12 +++++++++---
> gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C | 10 ++++++++++
> 2 files changed, 19 insertions(+), 3 deletions(-)
> create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C
>
> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> index c7bf7d412ca..bc0a0936579 100644
> --- a/gcc/cp/pt.c
> +++ b/gcc/cp/pt.c
> @@ -29097,9 +29097,15 @@ alias_ctad_tweaks (tree tmpl, tree uguides)
> /* Substitute the deduced arguments plus the rewritten template
> parameters into f to get g. This covers the type, copyness,
> guideness, and explicit-specifier. */
> - tree g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain);
> - if (g == error_mark_node)
> - continue;
> + tree g;
> + {
> + /* Parms are to have DECL_CHAIN tsubsted, which would be skipped
> + if cp_unevaluated_operand. */
> + cp_evaluated ev;
> + g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain);
> + if (g == error_mark_node)
> + continue;
> + }
> DECL_USE_TEMPLATE (g) = 0;
> fprime = build_template_decl (g, gtparms, false);
> DECL_TEMPLATE_RESULT (fprime) = g;
> diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C
> new file mode 100644
> index 00000000000..a473fff5dc7
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C
> @@ -0,0 +1,10 @@
> +// PR c++/101233
> +// { dg-do compile { target c++20 } }
> +
> +template<class T, class U>
> +struct A { A(T, U); };
> +
> +template<class T, class U>
> +using B = A<U, T>;
> +
> +using type = decltype(B{0, 0});
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-16 17:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 16:37 [PATCH] c++: alias CTAD inside decltype [PR101233] Patrick Palka
2021-07-16 17:16 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).