Fixed #5064 (Tokenizer::simplifySizeof: Doesn't simplify 'sizeof !! (a==1);' properly)
This commit is contained in:
parent
9cfc1030cd
commit
c234cace6d
|
@ -3320,9 +3320,17 @@ bool Tokenizer::simplifySizeof()
|
||||||
for (Token *tempToken = tok->next(); tempToken; tempToken = tempToken->next()) {
|
for (Token *tempToken = tok->next(); tempToken; tempToken = tempToken->next()) {
|
||||||
if (tempToken->str() == "(")
|
if (tempToken->str() == "(")
|
||||||
++parlevel;
|
++parlevel;
|
||||||
else if (tempToken->str() == ")")
|
else if (tempToken->str() == ")") {
|
||||||
--parlevel;
|
--parlevel;
|
||||||
if (Token::Match(tempToken, "%var%")) {
|
if (parlevel == 0 && !Token::Match(tempToken, ") . %var%")) {
|
||||||
|
// Ok, we should be clean. Add ) after tempToken
|
||||||
|
tok->insertToken("(");
|
||||||
|
tempToken->insertToken(")");
|
||||||
|
Token::createMutualLinks(tok->next(), tempToken->next());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parlevel == 0 && Token::Match(tempToken, "%var%")) {
|
||||||
while (tempToken && tempToken->next() && tempToken->next()->str() == "[") {
|
while (tempToken && tempToken->next() && tempToken->next()->str() == "[") {
|
||||||
tempToken = tempToken->next()->link();
|
tempToken = tempToken->next()->link();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1325,6 +1325,9 @@ private:
|
||||||
" int aa ; aa = sizeof ( * ( * a ) . b ) ; "
|
" int aa ; aa = sizeof ( * ( * a ) . b ) ; "
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(expected, tok(code));
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
|
||||||
|
// #5064 - sizeof !! (a == 1);
|
||||||
|
ASSERT_EQUALS("sizeof ( ! ! ( a == 1 ) ) ;", tok("sizeof !!(a==1);"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void sizeof15() {
|
void sizeof15() {
|
||||||
|
|
Loading…
Reference in New Issue