ValueFlow: Fix for if/else valueflow analysis
This commit is contained in:
parent
3d8ac3d0a1
commit
25846cf223
|
@ -1043,6 +1043,11 @@ static void execute(const Token *expr,
|
|||
execute(expr->astOperand2(), programMemory, result, error);
|
||||
}
|
||||
|
||||
else if (expr->str() == "!") {
|
||||
execute(expr->astOperand1(), programMemory, result, error);
|
||||
*result = !(*result);
|
||||
}
|
||||
|
||||
else
|
||||
*error = true;
|
||||
}
|
||||
|
|
|
@ -708,6 +708,13 @@ private:
|
|||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
|
||||
|
||||
code = "void f() {\n"
|
||||
" int x = 0;\n"
|
||||
" if (!x) {}\n"
|
||||
" else { y = x; }\n"
|
||||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
|
||||
|
||||
// multivariables
|
||||
code = "void f(int a) {\n"
|
||||
" int x = a;\n"
|
||||
|
|
Loading…
Reference in New Issue