Serialization/Deserialization of expansion statements.

Should fix #165.
This commit is contained in:
Dan Katz
2025-06-30 14:18:21 -04:00
parent 97a102f706
commit a2bd2164c0
9 changed files with 290 additions and 32 deletions

View File

@@ -1,5 +1,6 @@
module;
#include <meta>
#include <tuple>
export module Example;
namespace Example {
@@ -73,4 +74,21 @@ export constexpr auto rBase2 = bases_of(^^Child, ctx)[1];
export constexpr auto rTDMS = data_member_spec(^^int, {.name="test"});
// ====================
// Expansion statements
// ====================
void test() {
// Iterating expansion statement.
constexpr static auto sequence = std::array{0, 1, 2, 3, 4};
template for (constexpr auto i : sequence) { (void) i; }
// Destructurable expansion statement.
constexpr auto tup = std::make_tuple(1, true, 'c');
template for (constexpr auto i : tup) { (void) i; }
// Enumerating expansion statement.
template for (auto i : {1, 2, 3}) { (void) i; }
}
} // namespace Example

View File

@@ -2,10 +2,10 @@
//
// RUN: mkdir %t
// RUN: %{cxx} %{compile_flags} -std=c++26 \
// RUN: -freflection -fparameter-reflection \
// RUN: -freflection-latest \
// RUN: --precompile example-module.cppm -o %t/example-module.pcm
// RUN: %{cxx} %{compile_flags} %{link_flags} -std=c++26 \
// RUN: -freflection -fparameter-reflection \
// RUN: -freflection-latest \
// RUN: -fmodule-file=Example=%t/example-module.pcm %t/example-module.pcm \
// RUN: module-imports.sh.cpp -o %t/module-imports.sh.cpp.tsk
// RUN: %t/module-imports.sh.cpp.tsk > %t/stdout.txt