Fix crash on ternary with omitted operand (#4673)
* Fix MSVC compiler warning * Fix crash on incomplete ternary operator * Revert "Fix crash on incomplete ternary operator" This reverts commit 28df0f0ab6ff794e733617447f847a97c1a7a609. * Handle ternary with omitted operand
This commit is contained in:
parent
bf11cdf299
commit
11f1a9d1f5
|
@ -1744,6 +1744,8 @@ static bool isConvertedToIntegral(const Token* tok, const Settings* settings)
|
|||
|
||||
static bool isSameToken(const Token* tok1, const Token* tok2)
|
||||
{
|
||||
if (!tok1 || !tok2)
|
||||
return false;
|
||||
if (tok1->exprId() != 0 && tok1->exprId() == tok2->exprId())
|
||||
return true;
|
||||
if (tok1->hasKnownIntValue() && tok2->hasKnownIntValue())
|
||||
|
|
|
@ -1265,7 +1265,7 @@ private:
|
|||
void valueFlowMaxIterations() {
|
||||
REDIRECT;
|
||||
const char * const argv[] = {"cppcheck", "--valueflow-max-iterations=0"};
|
||||
settings.valueFlowMaxIterations = -1;
|
||||
settings.valueFlowMaxIterations = SIZE_MAX;
|
||||
ASSERT(defParser.parseFromArgs(2, argv));
|
||||
ASSERT_EQUALS(0, settings.valueFlowMaxIterations);
|
||||
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
|
||||
|
@ -1274,7 +1274,7 @@ private:
|
|||
void valueFlowMaxIterations2() {
|
||||
REDIRECT;
|
||||
const char * const argv[] = {"cppcheck", "--valueflow-max-iterations=11"};
|
||||
settings.valueFlowMaxIterations = -1;
|
||||
settings.valueFlowMaxIterations = SIZE_MAX;
|
||||
ASSERT(defParser.parseFromArgs(2, argv));
|
||||
ASSERT_EQUALS(11, settings.valueFlowMaxIterations);
|
||||
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
|
||||
|
|
|
@ -6839,6 +6839,12 @@ private:
|
|||
" std::shared_ptr<B> m;\n"
|
||||
"};\n";
|
||||
valueOfTok(code, "r");
|
||||
|
||||
code = "void g(int);\n"
|
||||
"void f(int x, int y) {\n"
|
||||
" g(x < y ? : 1);\n"
|
||||
"};\n";
|
||||
valueOfTok(code, "?");
|
||||
}
|
||||
|
||||
void valueFlowHang() {
|
||||
|
|
Loading…
Reference in New Issue