From 8a658fb9ecd48492a5cf6beefad8e691649aaf76 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 5 Dec 2023 08:02:51 -0500 Subject: Tests/CXXModules: import from an internal partition It is reported that MSVC doesn't support the `modname=` syntax in its `-reference modname=modname.ifc` for internal partitions. Add a test case. --- .../RunCMake/CXXModules/examples/internal-partitions/CMakeLists.txt | 3 ++- Tests/RunCMake/CXXModules/examples/internal-partitions/internal.cxx | 6 ++++++ .../RunCMake/CXXModules/examples/internal-partitions/partition.cxx | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/CXXModules/examples/internal-partitions/internal.cxx diff --git a/Tests/RunCMake/CXXModules/examples/internal-partitions/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/internal-partitions/CMakeLists.txt index bf99f7c..ecbae34 100644 --- a/Tests/RunCMake/CXXModules/examples/internal-partitions/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/internal-partitions/CMakeLists.txt @@ -19,7 +19,8 @@ target_sources(internal-partitions "${CMAKE_CURRENT_SOURCE_DIR}" FILES importable.cxx - partition.cxx) + partition.cxx + internal.cxx) target_compile_features(internal-partitions PUBLIC cxx_std_20) add_executable(exe) diff --git a/Tests/RunCMake/CXXModules/examples/internal-partitions/internal.cxx b/Tests/RunCMake/CXXModules/examples/internal-partitions/internal.cxx new file mode 100644 index 0000000..1e9d108 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/internal-partitions/internal.cxx @@ -0,0 +1,6 @@ +export module internal; + +export int from_internal() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx b/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx index c828612..3d3d92c 100644 --- a/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx +++ b/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx @@ -1,6 +1,7 @@ module importable:internal_partition; +import internal; int from_partition() { - return 0; + return from_internal(); } -- cgit v0.12 From e63983956d973e9f3bcc6af03eaf00bf0e3f59b5 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 5 Dec 2023 09:19:32 -0500 Subject: Tests/CXXModules: enhance `internal-partitions` test This test previously did not *require* that the internal partition be specified as a transitive usage because nothing from it was exposed. Plumb through usages such that the internal partitions are required. --- .../RunCMake/CXXModules/examples/internal-partitions/importable.cxx | 6 ++++++ Tests/RunCMake/CXXModules/examples/internal-partitions/internal.cxx | 5 +++++ Tests/RunCMake/CXXModules/examples/internal-partitions/main.cxx | 2 +- .../RunCMake/CXXModules/examples/internal-partitions/partition.cxx | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Tests/RunCMake/CXXModules/examples/internal-partitions/importable.cxx b/Tests/RunCMake/CXXModules/examples/internal-partitions/importable.cxx index 3b3d313..b180cb0 100644 --- a/Tests/RunCMake/CXXModules/examples/internal-partitions/importable.cxx +++ b/Tests/RunCMake/CXXModules/examples/internal-partitions/importable.cxx @@ -3,6 +3,12 @@ import :internal_partition; #include "internal-partitions_export.h" +export struct module_struct +{ +private: + partition_struct p; +}; + export INTERNAL_PARTITIONS_EXPORT int from_import() { return from_partition(); diff --git a/Tests/RunCMake/CXXModules/examples/internal-partitions/internal.cxx b/Tests/RunCMake/CXXModules/examples/internal-partitions/internal.cxx index 1e9d108..9dc1470 100644 --- a/Tests/RunCMake/CXXModules/examples/internal-partitions/internal.cxx +++ b/Tests/RunCMake/CXXModules/examples/internal-partitions/internal.cxx @@ -1,5 +1,10 @@ export module internal; +export struct internal_struct +{ + int x; +}; + export int from_internal() { return 0; diff --git a/Tests/RunCMake/CXXModules/examples/internal-partitions/main.cxx b/Tests/RunCMake/CXXModules/examples/internal-partitions/main.cxx index feb38d2..692a470 100644 --- a/Tests/RunCMake/CXXModules/examples/internal-partitions/main.cxx +++ b/Tests/RunCMake/CXXModules/examples/internal-partitions/main.cxx @@ -2,5 +2,5 @@ import importable; int main(int argc, char* argv[]) { - return from_import(); + return from_import() * sizeof(module_struct); } diff --git a/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx b/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx index 3d3d92c..67ab2ff3 100644 --- a/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx +++ b/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx @@ -1,6 +1,11 @@ module importable:internal_partition; import internal; +struct partition_struct +{ + internal_struct i; +}; + int from_partition() { return from_internal(); -- cgit v0.12