Fixed #5695 (FP: Mismatching assignment and comparison)

This commit is contained in:
Daniel Marjamäki 2014-05-06 19:35:47 +02:00
parent b354de6b23
commit 5ad3ac2653
2 changed files with 13 additions and 0 deletions

View File

@ -99,6 +99,8 @@ bool CheckAssignIf::assignIfParseScope(const Token * const assignTok,
}
return true;
}
if (Token::Match(tok2, "++|-- %varid%", varid) || Token::Match(tok2, "%varid% ++|--", varid))
return true;
if (Token::Match(tok2, "[(,] &| %varid% [,)]", varid)) {
unsigned int argumentNumber = 0;
const Token *ftok;

View File

@ -225,6 +225,17 @@ private:
" else if (rHitObject.IsClosedObj() && !&rHitObject) { }\n"
"}");
ASSERT_EQUALS("", errout.str());
// #5695: increment
check("void f(int a0, int n) {\n"
" int c = a0 & 3;\n"
" for (int a = 0; a < n; a++) {\n"
" c++;\n"
" if (c == 4)\n"
" c = 0;\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void mismatchingBitAnd() {