diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 57ace50f9..9d487ee8f 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1443,6 +1443,9 @@ void CheckOther::checkIncompleteStatement() continue; if (isVoidStmt(tok)) continue; + if (mTokenizer->isCPP() && tok->str() == "&" && !(tok->astOperand1()->valueType() && tok->astOperand1()->valueType()->isIntegral())) + // Possible archive + continue; bool inconclusive = Token::Match(tok, "%cop%"); if (mSettings->inconclusive || !inconclusive) constStatementError(tok, tok->isNumber() ? "numeric" : "string", inconclusive); diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index c49e45557..ad2905bf0 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -85,6 +85,7 @@ private: TEST_CASE(commaoperator); TEST_CASE(redundantstmts); TEST_CASE(vardecl); + TEST_CASE(archive); // ar & x } void test1() { @@ -366,6 +367,18 @@ private: check("void f() { char * const * a = 0, * volatile const * b; }", true); ASSERT_EQUALS("", errout.str()); } + + void archive() { + check("void f(Archive &ar) {\n" + " ar & x;\n" + "}", true); + ASSERT_EQUALS("", errout.str()); + + check("void f(int ar) {\n" + " ar & x;\n" + "}", true); + ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Found suspicious operator '&'\n", errout.str()); + } }; REGISTER_TEST(TestIncompleteStatement)