Fixed #5081 (False positive: (error) Uninitialized variable: f (handling of C-cast not correct))
This commit is contained in:
parent
6b4016be42
commit
0c5282b1af
|
@ -4838,9 +4838,9 @@ void Tokenizer::simplifyCasts()
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((Token::Match(tok->next(), "( %type% *| *| *| ) *|&| %var%") && (tok->str() != ")" || tok->tokAt(2)->isStandardType())) ||
|
while ((Token::Match(tok->next(), "( %type% *| *| *| ) *|&| %var%") && (tok->str() != ")" || tok->tokAt(2)->isStandardType())) ||
|
||||||
Token::Match(tok->next(), "( %type% %type% *| *| *| ) *|&| %var%") ||
|
Token::Match(tok->next(), "( const| %type% %type% *| *| *| ) *|&| %var%") ||
|
||||||
(!tok->isName() && (Token::Match(tok->next(), "( %type% * *| *| ) (") ||
|
(!tok->isName() && (Token::Match(tok->next(), "( %type% * *| *| ) (") ||
|
||||||
Token::Match(tok->next(), "( %type% %type% * *| *| ) (")))) {
|
Token::Match(tok->next(), "( const| %type% %type% * *| *| ) (")))) {
|
||||||
if (tok->isName() && tok->str() != "return")
|
if (tok->isName() && tok->str() != "return")
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,7 @@ private:
|
||||||
TEST_CASE(removeCast11);
|
TEST_CASE(removeCast11);
|
||||||
TEST_CASE(removeCast12);
|
TEST_CASE(removeCast12);
|
||||||
TEST_CASE(removeCast13);
|
TEST_CASE(removeCast13);
|
||||||
|
TEST_CASE(removeCast14);
|
||||||
|
|
||||||
TEST_CASE(simplifyFloatCasts); // float casting a integer
|
TEST_CASE(simplifyFloatCasts); // float casting a integer
|
||||||
|
|
||||||
|
@ -1130,6 +1131,11 @@ private:
|
||||||
tokenizeAndStringify("; float angle = (float) +tilt;", true));
|
tokenizeAndStringify("; float angle = (float) +tilt;", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeCast14() { // const
|
||||||
|
// #5081
|
||||||
|
ASSERT_EQUALS("( ! ( & s ) . a )", tokenizeAndStringify("(! ( (struct S const *) &s)->a)", true));
|
||||||
|
}
|
||||||
|
|
||||||
void simplifyFloatCasts() { // float casting integers
|
void simplifyFloatCasts() { // float casting integers
|
||||||
// C-style casts
|
// C-style casts
|
||||||
ASSERT_EQUALS("a = 1.0f ;", tokenizeAndStringify("a = (float)1;"));
|
ASSERT_EQUALS("a = 1.0f ;", tokenizeAndStringify("a = (float)1;"));
|
||||||
|
|
Loading…
Reference in New Issue