Fixed #8241 (FP: Same expression on both sides of operator)
This commit is contained in:
parent
2c61f40c35
commit
0425f1d46d
|
@ -5248,6 +5248,9 @@ void Tokenizer::simplifyPointerToStandardType()
|
|||
if (!Token::Match(tok, "& %name% [ 0 ] !!["))
|
||||
continue;
|
||||
|
||||
if (!Token::Match(tok->previous(), "[,(=]"))
|
||||
continue;
|
||||
|
||||
// Remove '[ 0 ]' suffix
|
||||
tok->next()->eraseTokens(tok->next(), tok->tokAt(5));
|
||||
// Remove '&' prefix
|
||||
|
|
|
@ -4712,6 +4712,10 @@ private:
|
|||
tokenizeAndStringify("char buf[100] ; readlink(path, &buf[0], 99);",
|
||||
false, true, Settings::Native, "test.c"));
|
||||
|
||||
ASSERT_EQUALS("void foo ( char * c ) { if ( 1 == ( 1 & c [ 0 ] ) ) { } }",
|
||||
tokenizeAndStringify("void foo(char *c) { if (1==(1 & c[0])) {} }",
|
||||
false, true, Settings::Native, "test.c"));
|
||||
|
||||
// Simplification of unknown type - C only
|
||||
ASSERT_EQUALS("foo data [ 100 ] ; something ( foo ) ;",
|
||||
tokenizeAndStringify("foo data[100]; something(&foo[0]);", false, true, Settings::Native, "test.c"));
|
||||
|
|
Loading…
Reference in New Issue