Skip to content

[BUG] Unused variable check only applies to a potentially movable local #890

Closed
@JohelEGP

Description

@JohelEGP

Title: Unused variable check only applies to a potentially movable local.

Minimal reproducer (https://cpp2.godbolt.org/z/jre1681ae):

f: (x) = { }
g: (copy y) = { }
main: () = { }
Commands:
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:
main.cpp2...
main.cpp2(2,10): error: local variable y is not used; consider changing its name to '_' to make it explicitly anonymous, or removing it entirely if its side effects are not needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions