Closed JohelEGP closed 6 months ago
Same for the test case of #869.
v: @union @print type = {
i: int;
}
prints
if that.is_i()
{
set_i(that.i());
}
which generates
if (CPP2_UFCS(is_i)(std::move(that))) {set_i(CPP2_UFCS(i)(std::move(that)));}
Title: Implicit move on non-last use.
Minimal reproducer (https://cpp2.godbolt.org/z/z1nWesaaa):
Commands:
```bash cppfront main.cpp2 clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -Werror=unused-parameter -Werror=unused-variable -I . main.cpp ```Expected result:
Actual result and error:
Cpp2 lowered to Cpp1:
```C++ //=== Cpp2 type declarations ==================================================== #include "cpp2util.h" #line 1 "/app/example.cpp2" //=== Cpp2 type definitions and function declarations =========================== #line 1 "/app/example.cpp2" auto main() -> int; //=== Cpp2 function definitions ================================================= #line 1 "/app/example.cpp2" auto main() -> int{ #line 2 "/app/example.cpp2" auto x {0}; if (true) {static_castOutput:
See also:
440.