diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 61a1f17ed..01a0e6228 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -1006,7 +1006,7 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens) // keep parentheses here: Functor()(a ... ) // keep parentheses here: ) ( var ) ; if ((Token::Match(tok->next(), "( %name% ) ;|)|,|]") || - (Token::Match(tok->next(), "( %name% ) %cop%") && (tok->tokAt(2)->varId()>0 || !Token::Match(tok->tokAt(4), "[*&+-]")))) && + (Token::Match(tok->next(), "( %name% ) %cop%") && (tok->tokAt(2)->varId()>0 || !Token::Match(tok->tokAt(4), "[*&+-~]")))) && !tok->isName() && tok->str() != ">" && tok->str() != ")" && diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index dfe4e22cb..aa8a14230 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -955,12 +955,9 @@ private: // #4899 - False positive on unused variable ASSERT_EQUALS("; float angle ; angle = tilt ;", tokenizeAndStringify("; float angle = (float) tilt;", true)); // status quo - TODO_ASSERT_EQUALS("; float angle ; angle = - tilt ;", - "; float angle ; angle = ( float ) - tilt ;", - tokenizeAndStringify("; float angle = (float) -tilt;", true)); - TODO_ASSERT_EQUALS("; float angle ; angle = tilt ;", - "; float angle ; angle = ( float ) + tilt ;", - tokenizeAndStringify("; float angle = (float) +tilt;", true)); + ASSERT_EQUALS("; float angle ; angle = ( float ) - tilt ;", tokenizeAndStringify("; float angle = (float) -tilt;", true)); + ASSERT_EQUALS("; float angle ; angle = ( float ) + tilt ;", tokenizeAndStringify("; float angle = (float) +tilt;", true)); + ASSERT_EQUALS("; int a ; a = ( int ) ~ c ;", tokenizeAndStringify("; int a = (int)~c;", true)); } void removeCast14() { // const