diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 9251d9c1d..0a67b73b3 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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% * *| *| ) (")))) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 0c03b0be9..b082905b3 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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 };"));