Fix #767 (Tokenizer: Known variable variable not simplified)
http://sourceforge.net/apps/trac/cppcheck/ticket/767
This commit is contained in:
parent
e5f13b4de2
commit
9d42194562
|
@ -3259,7 +3259,7 @@ bool Tokenizer::simplifyKnownVariables()
|
|||
}
|
||||
|
||||
// Variable is used in calculation..
|
||||
if (Token::Match(tok3, "[=+-*/[] %varid% [+-*/;]]", varid) ||
|
||||
if (Token::Match(tok3, "[=+-*/[] %varid% [?+-*/;]]", varid) ||
|
||||
Token::Match(tok3, "[=+-*/[] %varid% <<", varid) ||
|
||||
Token::Match(tok3, "<< %varid% [+-*/;]]", varid))
|
||||
{
|
||||
|
|
|
@ -1563,6 +1563,15 @@ private:
|
|||
const char code[] = "( true ? abc . a : abc . b )";
|
||||
ASSERT_EQUALS("( abc . a )", tok(code));
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
" bool x = false;\n"
|
||||
" int b = x ? 44 : 3;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS("void f ( ) { bool x ; x = false ; int b ; b = 3 ; }", tok(code));
|
||||
}
|
||||
}
|
||||
|
||||
void calculations()
|
||||
|
|
Loading…
Reference in New Issue