]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: replace in_template_function
authorPatrick Palka <ppalka@redhat.com>
Sat, 3 Jun 2023 13:17:31 +0000 (09:17 -0400)
committerPatrick Palka <ppalka@redhat.com>
Sat, 3 Jun 2023 13:17:31 +0000 (09:17 -0400)
commit557cc2b721432775a12fcafa60e9b8b0c320c29d
tree33493ec11a20985b1115833844360b8b9cafb8b7
parent999e617d3121b82921c8031ee695fd036f553f04
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.
gcc/cp/class.cc
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/decl2.cc
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/warn/Waddress-of-packed-member2.C