* [PATCH] c++: clear tf_partial et al in instantiate_template [PR108960]
@ 2023-07-25 19:55 Marek Polacek
2023-07-25 20:25 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2023-07-25 19:55 UTC (permalink / raw)
To: GCC Patches, Jason Merrill
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
-- >8 --
In <https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612929.html>
we concluded that we might clear all flags except tf_warning_or_error
when performing instantiate_template.
PR c++/108960
gcc/cp/ChangeLog:
* pt.cc (lookup_and_finish_template_variable): Don't clear tf_partial
here.
(instantiate_template): Reset all complain flags except
tf_warning_or_error.
---
gcc/cp/pt.cc | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 21b08a6266a..265e2a59a52 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -10396,12 +10396,6 @@ lookup_and_finish_template_variable (tree templ, tree targs,
tree var = lookup_template_variable (templ, targs, complain);
if (var == error_mark_node)
return error_mark_node;
- /* We may be called while doing a partial substitution, but the
- type of the variable template may be auto, in which case we
- will call do_auto_deduction in mark_used (which clears tf_partial)
- and the auto must be properly reduced at that time for the
- deduction to work. */
- complain &= ~tf_partial;
var = finish_template_variable (var, complain);
mark_used (var);
return var;
@@ -22008,6 +22002,14 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain)
if (tmpl == error_mark_node)
return error_mark_node;
+ /* The other flags are not relevant anymore here, especially tf_partial
+ shouldn't be set. For instance, we may be called while doing a partial
+ substitution of a template variable, but the type of the variable
+ template may be auto, in which case we will call do_auto_deduction
+ in mark_used (which clears tf_partial) and the auto must be properly
+ reduced at that time for the deduction to work. */
+ complain &= tf_warning_or_error;
+
gcc_assert (TREE_CODE (tmpl) == TEMPLATE_DECL);
if (modules_p ())
base-commit: 6e424febfbcb27c21a7fe3a137e614765f9cf9d2
--
2.41.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: clear tf_partial et al in instantiate_template [PR108960]
2023-07-25 19:55 [PATCH] c++: clear tf_partial et al in instantiate_template [PR108960] Marek Polacek
@ 2023-07-25 20:25 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2023-07-25 20:25 UTC (permalink / raw)
To: Marek Polacek, GCC Patches
On 7/25/23 15:55, Marek Polacek wrote:
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
OK.
> -- >8 --
>
> In <https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612929.html>
> we concluded that we might clear all flags except tf_warning_or_error
> when performing instantiate_template.
>
> PR c++/108960
>
> gcc/cp/ChangeLog:
>
> * pt.cc (lookup_and_finish_template_variable): Don't clear tf_partial
> here.
> (instantiate_template): Reset all complain flags except
> tf_warning_or_error.
> ---
> gcc/cp/pt.cc | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 21b08a6266a..265e2a59a52 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -10396,12 +10396,6 @@ lookup_and_finish_template_variable (tree templ, tree targs,
> tree var = lookup_template_variable (templ, targs, complain);
> if (var == error_mark_node)
> return error_mark_node;
> - /* We may be called while doing a partial substitution, but the
> - type of the variable template may be auto, in which case we
> - will call do_auto_deduction in mark_used (which clears tf_partial)
> - and the auto must be properly reduced at that time for the
> - deduction to work. */
> - complain &= ~tf_partial;
> var = finish_template_variable (var, complain);
> mark_used (var);
> return var;
> @@ -22008,6 +22002,14 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain)
> if (tmpl == error_mark_node)
> return error_mark_node;
>
> + /* The other flags are not relevant anymore here, especially tf_partial
> + shouldn't be set. For instance, we may be called while doing a partial
> + substitution of a template variable, but the type of the variable
> + template may be auto, in which case we will call do_auto_deduction
> + in mark_used (which clears tf_partial) and the auto must be properly
> + reduced at that time for the deduction to work. */
> + complain &= tf_warning_or_error;
> +
> gcc_assert (TREE_CODE (tmpl) == TEMPLATE_DECL);
>
> if (modules_p ())
>
> base-commit: 6e424febfbcb27c21a7fe3a137e614765f9cf9d2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-25 20:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-25 19:55 [PATCH] c++: clear tf_partial et al in instantiate_template [PR108960] Marek Polacek
2023-07-25 20:25 ` 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).