diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-10-11 15:02:01 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-10-11 15:02:01 -0400 |
commit | 2ceb4d531a303f3e70d8bb218c8759e6c0688f62 (patch) | |
tree | 18b790c3cc65b74989e6caa7a2757b23b8ba380b /gcc/cp | |
parent | 637e3668fdc17c4e226538fb14f9fab225433d01 (diff) | |
download | gcc-2ceb4d531a303f3e70d8bb218c8759e6c0688f62.zip gcc-2ceb4d531a303f3e70d8bb218c8759e6c0688f62.tar.gz gcc-2ceb4d531a303f3e70d8bb218c8759e6c0688f62.tar.bz2 |
c++ modules: lazy loading from within template [PR99377]
Here when lazily loading the binding for f due to its first use from the
template g, processing_template_decl is set which causes the call to
note_vague_linkage_fn from module_state::read_cluster to have no effect,
and thus we never push f onto deferred_fns and end up never emitting its
definition despite needing it.
The behavior of the lazy loading machinery shouldn't be sensitive to
whether we're inside a template, so to that end this patch makes us
clear processing_template_decl in the entrypoints lazy_load_binding and
lazy_load_pendings.
PR c++/99377
gcc/cp/ChangeLog:
* module.cc (lazy_load_binding): Clear processing_template_decl.
(lazy_load_pendings): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/modules/pr99377-2_a.C: New test.
* g++.dg/modules/pr99377-2_b.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/module.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 4d27ceb..7ffeefa 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -19083,6 +19083,10 @@ lazy_load_binding (unsigned mod, tree ns, tree id, binding_slot *mslot) timevar_start (TV_MODULE_IMPORT); + /* Make sure lazy loading from a template context behaves as if + from a non-template context. */ + processing_template_decl_sentinel ptds; + /* Stop GC happening, even in outermost loads (because our caller could well be building up a lookup set). */ function_depth++; @@ -19131,6 +19135,10 @@ lazy_load_binding (unsigned mod, tree ns, tree id, binding_slot *mslot) void lazy_load_pendings (tree decl) { + /* Make sure lazy loading from a template context behaves as if + from a non-template context. */ + processing_template_decl_sentinel ptds; + tree key_decl; pending_key key; key.ns = find_pending_key (decl, &key_decl); |