Fixed ticket #3176 (cppcheck reports wrong unused variable)
Label simplification didn't take count of the '(' parenthesis or the '&' and '*' operators inside or outside the parenthesis after the colon.
This commit is contained in:
parent
fe4ce594ce
commit
80df7ea839
|
@ -2834,7 +2834,7 @@ void Tokenizer::labels()
|
||||||
}
|
}
|
||||||
|
|
||||||
// simplify label..
|
// simplify label..
|
||||||
if (Token::Match(tok, "[;{}] %var% : %var%"))
|
if (Token::Match(tok, "[;{}] %var% : (| *|&| %var%"))
|
||||||
{
|
{
|
||||||
if (!Token::Match(tok->next(), "public|protected|private"))
|
if (!Token::Match(tok->next(), "public|protected|private"))
|
||||||
tok->tokAt(2)->insertToken(";");
|
tok->tokAt(2)->insertToken(";");
|
||||||
|
|
|
@ -5085,6 +5085,9 @@ private:
|
||||||
void labels()
|
void labels()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS(" void f(){ ab:; a=0;}", labels_("void f() { ab: a=0; }"));
|
ASSERT_EQUALS(" void f(){ ab:; a=0;}", labels_("void f() { ab: a=0; }"));
|
||||||
|
ASSERT_EQUALS(" void f(){ ab:;* b=0;}", labels_("void f() { ab: *b=0; }"));
|
||||||
|
ASSERT_EQUALS(" void f(){ ab:;& b=0;}", labels_("void f() { ab: &b=0; }"));
|
||||||
|
ASSERT_EQUALS(" void f(){ ab:;(* func)();}", labels_("void f() { ab: (*func)(); }"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check simplifyInitVar
|
// Check simplifyInitVar
|
||||||
|
|
Loading…
Reference in New Issue