ValueFlow: Fix for if/else valueflow analysis

This commit is contained in:
Daniel Marjamäki 2014-07-30 18:12:33 +02:00
parent 3d8ac3d0a1
commit 25846cf223
2 changed files with 12 additions and 0 deletions

View File

@ -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;
}

View File

@ -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"