isOppositeCond: Fixed FN

This commit is contained in:
Daniel Marjamäki 2015-02-01 13:03:38 +01:00
parent d091639080
commit d6c94e3828
2 changed files with 7 additions and 1 deletions

View File

@ -286,7 +286,7 @@ static bool isOverlappingCond(const Token * const cond1, const Token * const con
const MathLib::bigint value1 = MathLib::toLongNumber(num1->str()); const MathLib::bigint value1 = MathLib::toLongNumber(num1->str());
const MathLib::bigint value2 = MathLib::toLongNumber(num2->str()); const MathLib::bigint value2 = MathLib::toLongNumber(num2->str());
return (value2 > 0 && (value1 & value2) == value2); return ((value1 & value2) > 0);
} }
return false; return false;
} }

View File

@ -457,6 +457,12 @@ private:
" else if (x == 0) {}\n" " else if (x == 0) {}\n"
"}",false); "}",false);
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("void f(int x) {\n"
" if (x & 15) {}\n"
" else if (x == 40) {}\n"
"}",false);
ASSERT_EQUALS("[test.cpp:3]: (style) Expression is always false because 'else if' condition matches previous condition at line 2.\n", errout.str());
} }
void invalidMissingSemicolon() { void invalidMissingSemicolon() {