Fix #776 (Tokenizer: remove useless brackets around variable assignment)
http://sourceforge.net/apps/trac/cppcheck/ticket/776
This commit is contained in:
parent
fc684d7b5a
commit
5a0a5422c3
|
@ -3408,7 +3408,7 @@ bool Tokenizer::simplifyRedundantParanthesis()
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok->previous(), "[(!*] ( %var% )") && tok->next()->varId() != 0)
|
if (Token::Match(tok->previous(), "[(!*;] ( %var% )") && tok->next()->varId() != 0)
|
||||||
{
|
{
|
||||||
// We have "( var )", remove the paranthesis
|
// We have "( var )", remove the paranthesis
|
||||||
tok = tok->previous();
|
tok = tok->previous();
|
||||||
|
|
|
@ -417,6 +417,10 @@ private:
|
||||||
ASSERT_EQUALS("return p ;", tok("return (p);"));
|
ASSERT_EQUALS("return p ;", tok("return (p);"));
|
||||||
ASSERT_EQUALS("void f ( ) { int * p ; if ( ! * p ) { } }", tok("void f(){int *p; if (*(p) == 0) {}}"));
|
ASSERT_EQUALS("void f ( ) { int * p ; if ( ! * p ) { } }", tok("void f(){int *p; if (*(p) == 0) {}}"));
|
||||||
ASSERT_EQUALS("void f ( ) { int * p ; if ( ! * p ) { } }", tok("void f(){int *p; if (*p == 0) {}}"));
|
ASSERT_EQUALS("void f ( ) { int * p ; if ( ! * p ) { } }", tok("void f(){int *p; if (*p == 0) {}}"));
|
||||||
|
ASSERT_EQUALS("void f ( ) { int p ; p = 1 ; }", tok("void f(){int p; (p) = 1;}"));
|
||||||
|
ASSERT_EQUALS("void f ( ) { int p [ 10 ] ; p [ 0 ] = 1 ; }", tok("void f(){int p[10]; (p)[0] = 1;}"));
|
||||||
|
ASSERT_EQUALS("void f ( ) { int p ; if ( ! p ) { } }", tok("void f(){int p; if ((p) == 0) {}}"));
|
||||||
|
ASSERT_EQUALS("void f ( ) { int * p ; * p = 1 ; }", tok("void f(){int *p; *(p) = 1;}"));
|
||||||
|
|
||||||
// keep parantheses..
|
// keep parantheses..
|
||||||
ASSERT_EQUALS("= a ;", tok("= (char)a;"));
|
ASSERT_EQUALS("= a ;", tok("= (char)a;"));
|
||||||
|
|
Loading…
Reference in New Issue