diff options
author | Marek Polacek <polacek@redhat.com> | 2023-07-25 14:36:47 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2023-07-25 16:31:20 -0400 |
commit | 39004608e79b68fe7615a026ce58dea646dba20e (patch) | |
tree | 8b2f29ed21399d2f0f9632f7ca58e438b80d0062 | |
parent | 28e3d361ba0cfa7ea2f90706159a144eaf4b650e (diff) | |
download | gcc-39004608e79b68fe7615a026ce58dea646dba20e.zip gcc-39004608e79b68fe7615a026ce58dea646dba20e.tar.gz gcc-39004608e79b68fe7615a026ce58dea646dba20e.tar.bz2 |
c++: clear tf_partial et al in instantiate_template [PR108960]
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.
-rw-r--r-- | gcc/cp/pt.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 21b08a6..265e2a5 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 ()) |