diff options
author | Nathaniel Shead <nathanieloshead@gmail.com> | 2024-04-09 21:49:58 +1000 |
---|---|---|
committer | Nathaniel Shead <nathanieloshead@gmail.com> | 2024-05-01 15:58:42 +1000 |
commit | 0d0215b10dbbe39d655ceda4af283f288ec7680c (patch) | |
tree | a83c9164957d443ee6522efb159b04f8bb9ebef5 /gcc | |
parent | 79420dd344145819677b3f975bb305a778fcaf91 (diff) | |
download | gcc-0d0215b10dbbe39d655ceda4af283f288ec7680c.zip gcc-0d0215b10dbbe39d655ceda4af283f288ec7680c.tar.gz gcc-0d0215b10dbbe39d655ceda4af283f288ec7680c.tar.bz2 |
c++: Propagate using decls from partitions [PR114868]
The modules code currently neglects to set OVL_USING_P on the dependency
created for a using-decl, which causes it not to remember that the
OVL_EXPORT_P flag had been set on it when emitted from the primary
interface unit. This patch ensures that it occurs.
PR c++/114868
gcc/cp/ChangeLog:
* module.cc (depset::hash::add_binding_entity): Propagate
OVL_USING_P for using-declarations.
gcc/testsuite/ChangeLog:
* g++.dg/modules/using-15_a.C: New test.
* g++.dg/modules/using-15_b.C: New test.
* g++.dg/modules/using-15_c.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/module.cc | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/using-15_a.C | 14 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/using-15_b.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/using-15_c.C | 8 |
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 5b8ff5b..fac0301 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -13150,10 +13150,14 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) /* Ignore NTTP objects. */ return false; + bool unscoped_enum_const_p = false; if (!(flags & WMB_Using) && CP_DECL_CONTEXT (decl) != data->ns) { /* A using that lost its wrapper or an unscoped enum constant. */ + /* FIXME: Ensure that unscoped enums are differentiated from + 'using enum' declarations when PR c++/114683 is fixed. */ + unscoped_enum_const_p = (TREE_CODE (decl) == CONST_DECL); flags = WMB_Flags (flags | WMB_Using); if (DECL_MODULE_EXPORT_P (TREE_CODE (decl) == CONST_DECL ? TYPE_NAME (TREE_TYPE (decl)) @@ -13214,6 +13218,8 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) if (flags & WMB_Using) { decl = ovl_make (decl, NULL_TREE); + if (!unscoped_enum_const_p) + OVL_USING_P (decl) = true; if (flags & WMB_Export) OVL_EXPORT_P (decl) = true; } diff --git a/gcc/testsuite/g++.dg/modules/using-15_a.C b/gcc/testsuite/g++.dg/modules/using-15_a.C new file mode 100644 index 0000000..3f4bb6c --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-15_a.C @@ -0,0 +1,14 @@ +// PR c++/114868 +// { dg-additional-options "-fmodules-ts -Wno-global-module" } +// { dg-module-cmi M:a } + +module; +namespace foo { + void a(); +} +export module M:a; + +namespace bar { + // propagate usings from partitions + export using foo::a; +} diff --git a/gcc/testsuite/g++.dg/modules/using-15_b.C b/gcc/testsuite/g++.dg/modules/using-15_b.C new file mode 100644 index 0000000..4b0cb74 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-15_b.C @@ -0,0 +1,6 @@ +// PR c++/114868 +// { dg-additional-options "-fmodules-ts" } +// { dg-module-cmi M } + +export module M; +export import :a; diff --git a/gcc/testsuite/g++.dg/modules/using-15_c.C b/gcc/testsuite/g++.dg/modules/using-15_c.C new file mode 100644 index 0000000..74dd10a --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-15_c.C @@ -0,0 +1,8 @@ +// PR c++/114868 +// { dg-additional-options "-fmodules-ts" } +import M; + +int main() { + bar::a(); + foo::a(); // { dg-error "not been declared" } +} |