Fix 9765: FP: knownConditionTrueFalse handling of template function with ternary operator (#3443)
This commit is contained in:
parent
28bc717cbe
commit
928efe77fc
|
@ -663,7 +663,7 @@ static void setTokenValue(Token* tok, ValueFlow::Value value, const Settings* se
|
|||
if (std::find(values.begin(), values.end(), value) != values.end())
|
||||
setTokenValue(parent, value, settings);
|
||||
}
|
||||
} else {
|
||||
} else if (!value.isImpossible()) {
|
||||
// is condition only depending on 1 variable?
|
||||
nonneg int varId = 0;
|
||||
bool ret = false;
|
||||
|
|
|
@ -3223,6 +3223,14 @@ private:
|
|||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 4U, 13));
|
||||
ASSERT_EQUALS(true, testValueOfX(code, 4U, 26));
|
||||
|
||||
code = "void f(int* i) {\n"
|
||||
" if (!i) return;\n"
|
||||
" int * x = *i == 1 ? i : nullptr;\n"
|
||||
" int* a = x;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(true, testValueOfX(code, 4U, 0));
|
||||
ASSERT_EQUALS(false, testValueOfXImpossible(code, 4U, 0));
|
||||
}
|
||||
|
||||
void valueFlowForwardLambda() {
|
||||
|
|
Loading…
Reference in New Issue