Closed JohelEGP closed 6 months ago
It's also necessary to recognize shadowing.
In this case, the in
parameter f
is moved
instead of the last use of the first f
(https://cpp2.godbolt.org/z/W4nceobbv):
t: @struct type = {
f: (this) -> int == 0;
}
main: () = {
// {
f: _ = t().f();
assert(f == 0);
// }
(f := t().f()) assert(f == 0);
}
auto main() -> int{
// {
auto f {t().f()};
cpp2::Default.expects(f == 0, "");
{
auto const& f = t().f();
// }
cpp2::Default.expects(std::move(f) == 0, "");
}
}
Title: Unused variable check only applies to a potentially movable local.
Minimal reproducer (https://cpp2.godbolt.org/z/jre1681ae):
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: For
x
to be diagnosed as unused.Actual result and error: Only
y
is diagnosed as unused.Output: