parent
8b76a109ce
commit
2bccde0e3b
|
@ -1134,6 +1134,11 @@ void CheckCondition::checkIncorrectLogicOperator()
|
|||
if (inconclusive && !printInconclusive)
|
||||
continue;
|
||||
|
||||
const bool isUnknown = (expr1 && expr1->valueType() && expr1->valueType()->type == ValueType::UNKNOWN_TYPE) ||
|
||||
(expr2 && expr2->valueType() && expr2->valueType()->type == ValueType::UNKNOWN_TYPE);
|
||||
if (isUnknown)
|
||||
continue;
|
||||
|
||||
const bool isfloat = astIsFloat(expr1, true) || MathLib::isFloat(value1) || astIsFloat(expr2, true) || MathLib::isFloat(value2);
|
||||
|
||||
ErrorPath errorPath;
|
||||
|
@ -1442,6 +1447,12 @@ void CheckCondition::alwaysTrueFalse()
|
|||
if (!(constIfWhileExpression || constValExpr || compExpr || ternaryExpression || returnExpression))
|
||||
continue;
|
||||
|
||||
const Token* expr1 = tok->astOperand1(), *expr2 = tok->astOperand2();
|
||||
const bool isUnknown = (expr1 && expr1->valueType() && expr1->valueType()->type == ValueType::UNKNOWN_TYPE) ||
|
||||
(expr2 && expr2->valueType() && expr2->valueType()->type == ValueType::UNKNOWN_TYPE);
|
||||
if (isUnknown)
|
||||
continue;
|
||||
|
||||
// Don't warn when there are expanded macros..
|
||||
bool isExpandedMacro = false;
|
||||
visitAstNodes(tok, [&](const Token * tok2) {
|
||||
|
|
|
@ -1209,6 +1209,14 @@ private:
|
|||
" if (x && x != ZERO) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(int N) {\n" // #9789
|
||||
" T a[20] = { 0 };\n"
|
||||
" for (int i = 0; i < N; ++i) {\n"
|
||||
" if (0 < a[i] && a[i] < 1) {}\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void incorrectLogicOperator5() { // complex expressions
|
||||
|
|
Loading…
Reference in New Issue