Skip to content

Commit

Permalink
Fix #12525 false negative: constStatement (danmar#6155)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Mar 19, 2024
1 parent 1e6621c commit e2081e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,8 @@ static bool isType(const Token * tok, bool unknown)
{
if (tok && (tok->isStandardType() || (!tok->isKeyword() && Token::Match(tok, "%type%")) || tok->str() == "auto"))
return true;
if (tok && tok->varId())
return false;
if (Token::simpleMatch(tok, "::"))
return isType(tok->astOperand2(), unknown);
if (Token::simpleMatch(tok, "<") && tok->link())
Expand Down
5 changes: 5 additions & 0 deletions test/testincompletestatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,11 @@ class TestIncompleteStatement : public TestFixture {
"}\n", /*inconclusive*/ true);
ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Found suspicious operator '*', result is not used.\n", errout_str());

check("void f(int x, int y) {\n" // #12525
" x * y;\n"
"}\n", /*inconclusive*/ true);
ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Found suspicious operator '*', result is not used.\n", errout_str());

check("void f() {\n" // #5475
" std::string(\"a\") + \"a\";\n"
"}\n"
Expand Down

0 comments on commit e2081e8

Please sign in to comment.