Fixed #4735 (FP: Mismatching assignment and comparison)
This commit is contained in:
parent
a5b044a6e2
commit
e1dd14626c
|
@ -52,7 +52,12 @@ void CheckAssignIf::assignIf()
|
||||||
bitop = tok->strAt(2).at(0);
|
bitop = tok->strAt(2).at(0);
|
||||||
num = MathLib::toLongNumber(tok->next()->str());
|
num = MathLib::toLongNumber(tok->next()->str());
|
||||||
} else {
|
} else {
|
||||||
const Token * const endToken = Token::findsimplematch(tok, ";");
|
const Token *endToken = Token::findsimplematch(tok, ";");
|
||||||
|
|
||||||
|
// Casting address
|
||||||
|
if (Token::Match(endToken->tokAt(-4), "* ) & %any% ;"))
|
||||||
|
endToken = NULL;
|
||||||
|
|
||||||
if (endToken && Token::Match(endToken->tokAt(-2), "[&|] %num% ;")) {
|
if (endToken && Token::Match(endToken->tokAt(-2), "[&|] %num% ;")) {
|
||||||
bitop = endToken->strAt(-2).at(0);
|
bitop = endToken->strAt(-2).at(0);
|
||||||
num = MathLib::toLongNumber(endToken->previous()->str());
|
num = MathLib::toLongNumber(endToken->previous()->str());
|
||||||
|
|
|
@ -173,6 +173,13 @@ private:
|
||||||
" if(x != -1) { }\n"
|
" if(x != -1) { }\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #4735
|
||||||
|
check("void f() {\n"
|
||||||
|
" int x = *(char*)&0x12345678;\n"
|
||||||
|
" if (x==18) { }\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void mismatchingBitAnd() {
|
void mismatchingBitAnd() {
|
||||||
|
|
Loading…
Reference in New Issue