value flow: Fixed FP in ?:
This commit is contained in:
parent
740f72fdbd
commit
1fb0b1750c
|
@ -62,6 +62,11 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, ErrorLogger *errorLog
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (Token::Match(tok->astParent(), "[?:]")) {
|
||||||
|
if (settings->debugwarnings)
|
||||||
|
bailout(tokenlist, errorLogger, tok, "variable " + var->nameToken()->str() + " stopping on " + tok->astParent()->str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
} else if (Token::Match(tok->previous(), "if|while ( %var% %oror%|&&|)") ||
|
} else if (Token::Match(tok->previous(), "if|while ( %var% %oror%|&&|)") ||
|
||||||
Token::Match(tok, "%oror%|&& %var% %oror%|&&|)")) {
|
Token::Match(tok, "%oror%|&& %var% %oror%|&&|)")) {
|
||||||
varid = tok->next()->varId();
|
varid = tok->next()->varId();
|
||||||
|
|
|
@ -82,6 +82,12 @@ private:
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(true, testValueOfX(code, 2U, 123));
|
ASSERT_EQUALS(true, testValueOfX(code, 2U, 123));
|
||||||
|
|
||||||
|
// bailout: ?:
|
||||||
|
bailout("void f(int x) {\n"
|
||||||
|
" y = ((x<0) ? x : ((x==2)?3:4));\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:2]: (debug) ValueFlow bailout: variable x stopping on :\n", errout.str());
|
||||||
|
|
||||||
// bailout: if/else/etc
|
// bailout: if/else/etc
|
||||||
bailout("void f(int x) {\n"
|
bailout("void f(int x) {\n"
|
||||||
" if (x != 123) { b = x; }\n"
|
" if (x != 123) { b = x; }\n"
|
||||||
|
|
Loading…
Reference in New Issue