Fixed #7056 (iscast does not handle '(ulong)~0' properly, Tokenizer::simplifyCalculations wrongly simplifies '(ulong)~0' to 'ulong~0')

This commit is contained in:
Daniel Marjamäki 2015-10-17 18:58:13 +02:00
parent 30af2fcd73
commit ec87b09d89
2 changed files with 4 additions and 7 deletions

View File

@ -1006,7 +1006,7 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
// keep parentheses here: Functor()(a ... ) // keep parentheses here: Functor()(a ... )
// keep parentheses here: ) ( var ) ; // keep parentheses here: ) ( var ) ;
if ((Token::Match(tok->next(), "( %name% ) ;|)|,|]") || 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->isName() &&
tok->str() != ">" && tok->str() != ">" &&
tok->str() != ")" && tok->str() != ")" &&

View File

@ -955,12 +955,9 @@ private:
// #4899 - False positive on unused variable // #4899 - False positive on unused variable
ASSERT_EQUALS("; float angle ; angle = tilt ;", tokenizeAndStringify("; float angle = (float) tilt;", true)); // status quo ASSERT_EQUALS("; float angle ; angle = tilt ;", tokenizeAndStringify("; float angle = (float) tilt;", true)); // status quo
TODO_ASSERT_EQUALS("; float angle ; angle = - tilt ;", ASSERT_EQUALS("; float angle ; angle = ( float ) - tilt ;", tokenizeAndStringify("; float angle = (float) -tilt;", true));
"; float angle ; angle = ( float ) - tilt ;", ASSERT_EQUALS("; float angle ; angle = ( float ) + tilt ;", tokenizeAndStringify("; float angle = (float) +tilt;", true));
tokenizeAndStringify("; float angle = (float) -tilt;", true)); ASSERT_EQUALS("; int a ; a = ( int ) ~ c ;", tokenizeAndStringify("; int a = (int)~c;", true));
TODO_ASSERT_EQUALS("; float angle ; angle = tilt ;",
"; float angle ; angle = ( float ) + tilt ;",
tokenizeAndStringify("; float angle = (float) +tilt;", true));
} }
void removeCast14() { // const void removeCast14() { // const