diff options
author | Patrick Palka <ppalka@redhat.com> | 2024-05-02 21:14:30 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2024-05-02 21:14:30 -0400 |
commit | f04dc89a991ddc6c08ac92c8ad29c6915c4ecafa (patch) | |
tree | c892aae902e897e1376789191b2ae42d7a6324df /gcc/tree-inline.cc | |
parent | a561dc0f6c7085e102fe9e9b6abd7f2138512576 (diff) | |
download | gcc-f04dc89a991ddc6c08ac92c8ad29c6915c4ecafa.zip gcc-f04dc89a991ddc6c08ac92c8ad29c6915c4ecafa.tar.gz gcc-f04dc89a991ddc6c08ac92c8ad29c6915c4ecafa.tar.bz2 |
c++: remove lookup_template_class's entering_scope flag
lookup_template_class's entering_scope flag controls whether to prefer
returning the primary template type A<T> instead of the corresponding
implicit instantiation A<T>. When we want to set this flag as part of
substitution, we need to use tsubst_aggr_type which also takes this flag
as a parameter. But having this separate entry point to type substitution
turned out to be subtly problematic because it doesn't reuse typedefs
like tsubst does, which r13-4729-gbe124477b38a71 fixed in a way that
respects the flag after the fact, by adjusting the entering_scope=false
result of lookup_template_class as if entering_scope=true was passed.
But if that's possible then it means lookup_template_class's
entering_scope flag is not necessary after all -- we can just do the
after-the-fact adjustment everywhere that we currently pass
entering_scope=true to it and tsubst_aggr_type.
To that end, this patch replaces this flag with an adjustment function
adjust_type_for_entering_scope, to be used whereever we currently need
the entering_scope=true behavior. In turn we can get rid of
tsubst_aggr_type since the only reason we needed this entry point
was to be able to pass entering_scope=true to lookup_template_class.
gcc/cp/ChangeLog:
* coroutines.cc (instantiate_coro_traits): Adjust call to
lookup_template_class.
(instantiate_coro_handle_for_promise_type): Likewise.
* cp-tree.h (adjust_type_for_entering_scope): Declare.
(lookup_template_class): Adjust declaration.
* decl.cc (make_typename_type): Adjust call to
lookup_template_class. Likewise.
(get_tuple_size): Likewise.
(get_tuple_element_type): Likewise.
* pt.cc (adjust_type_for_entering_scope): Define.
(tsubst_entering_scope): Define.
(lookup_template_class): Remove entering_scope parameter.
Replace tsubst_aggr_type call with tsubst_entering_scope.
(tsubst_aggr_type): Remove.
(tsubst_aggr_type_1): Inline into tsubst.
(tsubst_function_decl): Replace tsubst_aggr_type call
with tsubst_entering_scope.
(tsubst_template_decl): Likewise.
(tsubst_decl): Likewise.
(tsubst) <case RECORD_TYPE, UNION_TYPE, ENUMERAL_TYPE>:
Inlined from tsubst_aggr_type_1.
<case BOUND_TEMPLATE_TEMPLATE_PARM>: Adjust calls to
lookup_template_class.
<case TYPENAME_TYPE>: Replace tsubst_aggr_type call with
tsubst_entering_scope.
<case UNBOUND_CLASS_TEMPLATE>: Likewise.
Increment processing_template_decl when substituting the
context.
(tsubst_expr) <case FIELD_DECL>: Replace tsubst_aggr_type
call with tsubst_entering_scope.
<case TEMPLATE_DECL>: Likewise.
(instantiate_template): Likewise.
(resolve_typename_type): Adjust lookup_template_class call
and call adjust_type_for_entering_scope afterward.
(listify): Adjust lookup_template_class call.
(alias_ctad_tweaks): Likewise.
* semantics.cc (finish_template_type): Adjust lookup_template_class
call and maybe call adjust_type_for_entering_scope afterward.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/tree-inline.cc')
0 files changed, 0 insertions, 0 deletions