Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12525 false negative: constStatement #6155

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading