Fixed #2368 (assigned a value that is never used)
This commit is contained in:
parent
46c03973ee
commit
92acca3d0c
|
@ -4561,7 +4561,10 @@ void Tokenizer::simplifyCompoundAssignment()
|
|||
else if (str=="<<=" || str==">>=")
|
||||
op = str.substr(0, 2);
|
||||
else
|
||||
{
|
||||
tok = tok1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove the whole statement if it says: "+=0;", "-=0;", "*=1;" or "/=1;"
|
||||
if (Token::Match(tok, "+=|-= 0 ;") ||
|
||||
|
|
|
@ -5055,6 +5055,9 @@ private:
|
|||
ASSERT_EQUALS(";", tokenizeAndStringify(";x /= 1;"));
|
||||
|
||||
ASSERT_EQUALS("; a . x ( ) = a . x ( ) + 1 ;", tokenizeAndStringify("; a.x() += 1;"));
|
||||
|
||||
// #2368
|
||||
ASSERT_EQUALS("if ( false ) { } else { j = j - i ; }", tokenizeAndStringify("if (false) {} else { j -= i; }"));
|
||||
}
|
||||
|
||||
void simplifyAssignmentInFunctionCall()
|
||||
|
|
|
@ -1361,22 +1361,14 @@ private:
|
|||
|
||||
void localvar34() // ticket #2368
|
||||
{
|
||||
functionVariableUsage("int f(void) {\n"
|
||||
" int i = 0;\n"
|
||||
" int j = 3;\n"
|
||||
" if (false) {\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" j -= i;\n"
|
||||
" }\n"
|
||||
" if (false) {\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" j -= i;\n"
|
||||
" }\n"
|
||||
" return j;\n"
|
||||
functionVariableUsage("void f() {\n"
|
||||
" int i = 0;\n"
|
||||
" if (false) {\n"
|
||||
" } else {\n"
|
||||
" j -= i;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
TODO_ASSERT_EQUALS("", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias1()
|
||||
|
|
Loading…
Reference in New Issue