Skip to content

Commit

Permalink
Fix #12899 FN unusedFunction with enum value in braced initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 4, 2024
1 parent ae867c2 commit ad71024
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checkunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const Setting
continue;
}

if (!funcname || funcname->isKeyword() || funcname->isStandardType() || funcname->varId())
if (!funcname || funcname->isKeyword() || funcname->isStandardType() || funcname->varId() || funcname->enumerator())
continue;

// funcname ( => Assert that the end parentheses isn't followed by {
Expand Down
9 changes: 9 additions & 0 deletions test/testunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,15 @@ class TestUnusedFunctions : public TestFixture {
ASSERT_EQUALS("[test.cpp:4]: (style) The function 'Break' is never used.\n"
"[test.cpp:5]: (style) The function 'Break1' is never used.\n",
errout_str());

check("struct S {\n" // #12899
" void f() {}\n"
"};\n"
"enum E { f };\n"
"int main() {\n"
" E e{ f };\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2]: (style) The function 'f' is never used.\n", errout_str());
}

void recursive() {
Expand Down

0 comments on commit ad71024

Please sign in to comment.