Tokenizer::simplifyCasts: don't simplify 'f((double)(v1)*v2)' to 'f(*v2)'

This commit is contained in:
Daniel Marjamäki 2012-02-18 14:26:00 +01:00
parent 2ba2a4e6ae
commit 0705dbd34a
2 changed files with 6 additions and 1 deletions

View File

@ -4765,7 +4765,7 @@ void Tokenizer::simplifyCasts()
tok = tok->linkAt(2);
continue;
}
while (Token::Match(tok->next(), "( %type% *| *| *| ) *|&| %var%") ||
while ((Token::Match(tok->next(), "( %type% *| *| *| ) *|&| %var%") && (tok->str() != ")" || tok->tokAt(2)->isStandardType())) ||
Token::Match(tok->next(), "( %type% %type% *| *| *| ) *|&| %var%") ||
(!tok->isName() && (Token::Match(tok->next(), "( %type% * *| *| ) (") ||
Token::Match(tok->next(), "( %type% %type% * *| *| ) (")))) {

View File

@ -73,6 +73,7 @@ private:
TEST_CASE(removeCast6);
TEST_CASE(removeCast7);
TEST_CASE(removeCast8);
TEST_CASE(removeCast9);
TEST_CASE(inlineasm);
@ -775,6 +776,10 @@ private:
ASSERT_EQUALS("ptr1 = ptr2", tokenizeAndStringify("ptr1=(int * **)ptr2", true));
}
void removeCast9() {
ASSERT_EQUALS("f ( ( double ) v1 * v2 )", tokenizeAndStringify("f((double)(v1)*v2)", true));
}
void inlineasm() {
ASSERT_EQUALS("asm ( \"mov ax , bx\" ) ;", tokenizeAndStringify("asm { mov ax,bx };"));
ASSERT_EQUALS("asm ( \"mov ax , bx\" ) ;", tokenizeAndStringify("_asm { mov ax,bx };"));