diff options
author | Jason Merrill <jason@redhat.com> | 2023-12-18 15:47:10 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2024-01-12 12:14:36 -0500 |
commit | 27521a2f4f7b859d5656e5bdd69d3f759ea4c23a (patch) | |
tree | 4dd1dcd7b4ccc4d33bf89e20555e3bacaa6714ee /gcc/cp | |
parent | 9dadc9ccddacc984dbbad1f2cc6fd12ee63fee01 (diff) | |
download | gcc-27521a2f4f7b859d5656e5bdd69d3f759ea4c23a.zip gcc-27521a2f4f7b859d5656e5bdd69d3f759ea4c23a.tar.gz gcc-27521a2f4f7b859d5656e5bdd69d3f759ea4c23a.tar.bz2 |
c++: __class_type_info and modules [PR113038]
Doing a dynamic_cast in both TUs broke because we were declaring a new
__class_type_info in _b that conflicted with the one imported in the global
module from _a. It seems clear to me that any new class declaration in
the global module should merge with an imported definition, but for GCC 14
let's just fix this for the specific case of __class_type_info.
PR c++/113038
gcc/cp/ChangeLog:
* name-lookup.cc (lookup_elaborated_type): Look for bindings
in the global namespace in the ABI namespace.
gcc/testsuite/ChangeLog:
* g++.dg/modules/pr106304_b.C: Add dynamic_cast.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/name-lookup.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 26c6bc7..d827d33 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -8089,9 +8089,19 @@ lookup_elaborated_type (tree name, TAG_how how) { /* We're in the global module, perhaps there's a tag there? */ - // FIXME: This isn't quite right, if we find something - // here, from the language PoV we're not supposed to - // know it? + + /* FIXME: In general we should probably merge global module + classes in check_module_override rather than here, but for + GCC14 let's just fix lazy declarations of __class_type_info in + build_dynamic_cast_1. */ + if (current_namespace == abi_node) + { + tree g = (BINDING_VECTOR_CLUSTER (*slot, 0) + .slots[BINDING_SLOT_GLOBAL]); + for (ovl_iterator iter (g); iter; ++iter) + if (qualify_lookup (*iter, LOOK_want::TYPE)) + return *iter; + } } } } |