Support cast to ** in Tokenizer::simplifyCasts() (#7005)
This commit is contained in:
parent
590f1f1d66
commit
e6467703b2
|
@ -4927,7 +4927,7 @@ void Tokenizer::simplifyCasts()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace pointer casts of 0.. "(char *)0" => "0"
|
// Replace pointer casts of 0.. "(char *)0" => "0"
|
||||||
while (Token::Match(tok->next(), "( %type% %type%| * ) 0")) {
|
while (Token::Match(tok->next(), "( %type% %type%| * *| ) 0")) {
|
||||||
tok->linkAt(1)->next()->isCast(true);
|
tok->linkAt(1)->next()->isCast(true);
|
||||||
Token::eraseTokens(tok, tok->next()->link()->next());
|
Token::eraseTokens(tok, tok->next()->link()->next());
|
||||||
if (tok->str() == ")" && tok->link()->previous()) {
|
if (tok->str() == ")" && tok->link()->previous()) {
|
||||||
|
|
|
@ -370,6 +370,7 @@ private:
|
||||||
ASSERT_EQUALS("class A { A operator* ( int ) ; } ;", tok("class A { A operator *(int); };"));
|
ASSERT_EQUALS("class A { A operator* ( int ) ; } ;", tok("class A { A operator *(int); };"));
|
||||||
ASSERT_EQUALS("class A { A operator* ( int ) const ; } ;", tok("class A { A operator *(int) const; };"));
|
ASSERT_EQUALS("class A { A operator* ( int ) const ; } ;", tok("class A { A operator *(int) const; };"));
|
||||||
ASSERT_EQUALS("if ( p == 0 ) { ; }", tok("if (p == (char *)(char *)0);"));
|
ASSERT_EQUALS("if ( p == 0 ) { ; }", tok("if (p == (char *)(char *)0);"));
|
||||||
|
ASSERT_EQUALS("if ( p == 0 ) { ; }", tok("if (p == (char **)0);"));
|
||||||
|
|
||||||
// no simplification as the cast may be important here. see #2897 for example
|
// no simplification as the cast may be important here. see #2897 for example
|
||||||
ASSERT_EQUALS("; * ( ( char * ) p + 1 ) = 0 ;", tok("; *((char *)p + 1) = 0;"));
|
ASSERT_EQUALS("; * ( ( char * ) p + 1 ) = 0 ;", tok("; *((char *)p + 1) = 0;"));
|
||||||
|
|
Loading…
Reference in New Issue