Incomplete statement: Fix FP for 'ar & x'
This commit is contained in:
parent
73433c2961
commit
29a5404d1e
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue