diff options
author | Patrick Palka <ppalka@redhat.com> | 2023-06-03 09:17:31 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2023-06-03 09:17:31 -0400 |
commit | 557cc2b721432775a12fcafa60e9b8b0c320c29d (patch) | |
tree | 33493ec11a20985b1115833844360b8b9cafb8b7 /gcc/cp/cp-tree.h | |
parent | 999e617d3121b82921c8031ee695fd036f553f04 (diff) | |
download | gcc-557cc2b721432775a12fcafa60e9b8b0c320c29d.zip gcc-557cc2b721432775a12fcafa60e9b8b0c320c29d.tar.gz gcc-557cc2b721432775a12fcafa60e9b8b0c320c29d.tar.bz2 |
c++: replace in_template_function
All uses of in_template_function except for the one in cp_make_fname_decl
seem like they could be generalized to consider any template context.
To that end this patch replaces the predicate with a generalized
in_template_context predicate that returns true if we're inside any
template context. If we legitimately need to consider only function
contexts, as in cp_make_fname_decl, we can just additionally check e.g.
current_function_decl.
One concrete benefit of this, which the adjusted testcase below
demonstrates, is that we no longer instantiate/odr-use entities based on
uses within a non-function template.
gcc/cp/ChangeLog:
* class.cc (build_base_path): Check in_template_context instead
of in_template_function.
(resolves_to_fixed_type_p): Likewise.
* cp-tree.h (in_template_context): Define.
(in_template_function): Remove.
* decl.cc (cp_make_fname_decl): Check current_function_decl
and in_template_context instead of in_template_function.
* decl2.cc (mark_used): Check in_template_context instead of
in_template_function.
* pt.cc (in_template_function): Remove.
* semantics.cc (enforce_access): Check in_template_context
instead of current_template_parms directly.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Waddress-of-packed-member2.C: No longer expect a()
to be marked as odr-used.
Diffstat (limited to 'gcc/cp/cp-tree.h')
-rw-r--r-- | gcc/cp/cp-tree.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a1b882f..ce2095c 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1924,6 +1924,7 @@ extern GTY(()) struct saved_scope *scope_chain; #define current_template_parms scope_chain->template_parms #define current_template_depth \ (current_template_parms ? TMPL_PARMS_DEPTH (current_template_parms) : 0) +#define in_template_context (current_template_parms != NULL_TREE) #define processing_template_decl scope_chain->x_processing_template_decl #define processing_specialization scope_chain->x_processing_specialization @@ -7353,7 +7354,6 @@ extern tree lookup_template_variable (tree, tree); extern bool uses_template_parms (tree); extern bool uses_template_parms_level (tree, int); extern bool uses_outer_template_parms_in_constraints (tree); -extern bool in_template_function (void); extern bool need_generic_capture (void); extern tree instantiate_class_template (tree); extern tree instantiate_template (tree, tree, tsubst_flags_t); |