Partial fix for #10358: set value for int s = int(4); (#3523)

This commit is contained in:
chrchr-github 2021-11-08 20:28:55 +01:00 committed by GitHub
parent 60fd53ec09
commit b4561229cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -241,6 +241,12 @@ private:
inconclusive = false;
ASSERT_EQUALS(false, isVariableChangedByFunctionCall(code, "x ) ;", &inconclusive));
ASSERT_EQUALS(true, inconclusive);
code = "int f(int x) {\n"
"return int(x);\n"
"}\n";
ASSERT_EQUALS(false, isVariableChangedByFunctionCall(code, "x ) ;", &inconclusive));
TODO_ASSERT_EQUALS(false, true, inconclusive);
}
bool nextAfterAstRightmostLeaf(const char code[], const char parentPattern[], const char rightPattern[]) {

View File

@ -4402,6 +4402,22 @@ private:
ASSERT(value.isKnown());
ASSERT_EQUALS(1, value.intvalue);
code = "bool f() {\n"
" const int s = int( 4 );"
" return s == 4;\n" // <- known value
"}";
value = valueOfTok(code, "==");
ASSERT(value.isKnown());
ASSERT_EQUALS(1, value.intvalue);
code = "bool f() {\n"
" const int s = int{ 4 };"
" return s == 4;\n" // <- known value
"}";
value = valueOfTok(code, "==");
ASSERT(value.isKnown());
ASSERT_EQUALS(1, value.intvalue);
// calculation with known result
code = "int f(int x) { a = x & 0; }"; // <- & is 0
value = valueOfTok(code, "&");