diff --git a/lib/checkother.cpp b/lib/checkother.cpp index de39f5bdcda..5af22c7b2c5 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2299,7 +2299,7 @@ void CheckOther::checkIncompleteStatement() if (!Token::simpleMatch(tok->astParent(), ";") && !Token::simpleMatch(rtok, ";") && !Token::Match(tok->previous(), ";|}|{ %any% ;") && !(tok->isCpp() && tok->isCast() && !tok->astParent()) && - !(!tok->astParent() && Token::Match(tok->previous(), "%name% (") && tok->previous()->isKeyword()) && + !(!tok->astParent() && tok->astOperand1() && Token::Match(tok->previous(), "%name% (") && tok->previous()->isKeyword()) && !Token::simpleMatch(tok->tokAt(-2), "for (") && !Token::Match(tok->tokAt(-1), "%var% [") && !(tok->str() == "," && tok->astParent() && tok->astParent()->isAssignmentOp())) diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index afdacb77c51..f1694ea262f 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -743,6 +743,11 @@ class TestIncompleteStatement : public TestFixture { "[test.cpp:4:13]: (warning) Redundant code: Found unused 'noexcept' expression. [constStatement]\n" "[test.cpp:5:11]: (warning) Redundant code: Found unused 'typeid' expression. [constStatement]\n", errout_str()); + + check("void f() {\n" // #14044 + " g();\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void vardecl() {