Fixed #2398 (false positive: Uninitialized variable)
This commit is contained in:
parent
3cf4e74013
commit
63c1ee375e
|
@ -6314,7 +6314,7 @@ bool Tokenizer::simplifyKnownVariables()
|
|||
if (tok3->varId() == varid)
|
||||
{
|
||||
// Continue
|
||||
tok2 = bailOutFromLoop;
|
||||
//tok2 = bailOutFromLoop;
|
||||
break;
|
||||
}
|
||||
else if (tok3 == bailOutFromLoop)
|
||||
|
|
|
@ -125,6 +125,7 @@ private:
|
|||
TEST_CASE(simplifyKnownVariables34);
|
||||
TEST_CASE(simplifyKnownVariables35); // ticket #2353 - False positive: Division by zero 'if (x == 0) return 0; return 10 / x;'
|
||||
TEST_CASE(simplifyKnownVariables36); // ticket #2304 - known value for strcpy parameter
|
||||
TEST_CASE(simplifyKnownVariables37); // ticket #2398 - false positive caused by no simplification in for loop
|
||||
TEST_CASE(simplifyKnownVariablesBailOutAssign);
|
||||
TEST_CASE(simplifyKnownVariablesBailOutFor1);
|
||||
TEST_CASE(simplifyKnownVariablesBailOutFor2);
|
||||
|
@ -1918,6 +1919,28 @@ private:
|
|||
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true));
|
||||
}
|
||||
|
||||
void simplifyKnownVariables37()
|
||||
{
|
||||
// Ticket #2398 - no simplication in for loop
|
||||
const char code[] = "void f() {\n"
|
||||
" double x = 0;\n"
|
||||
" for (int iter=0; iter<42; iter++) {\n"
|
||||
" int EvaldF = 1;\n"
|
||||
" if (EvaldF)\n"
|
||||
" Eval (x);\n"
|
||||
" }\n"
|
||||
"}";
|
||||
const char expected[] = "void f ( ) {\n"
|
||||
"double x ; x = 0 ;\n"
|
||||
"for ( int iter = 0 ; iter < 42 ; iter ++ ) {\n"
|
||||
";\n"
|
||||
"{\n"
|
||||
"Eval ( x ) ; }\n"
|
||||
"}\n"
|
||||
"}";
|
||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true));
|
||||
}
|
||||
|
||||
void simplifyKnownVariablesBailOutAssign()
|
||||
{
|
||||
const char code[] = "int foo() {\n"
|
||||
|
|
Loading…
Reference in New Issue