Fixed #5244 (FP: (error) Uninitialized variable: ptr - initialization within if-clause)

This commit is contained in:
Daniel Marjamäki 2014-03-18 06:37:19 +01:00
parent a3bc80bd7d
commit 177bf6fcb3
2 changed files with 3 additions and 0 deletions

View File

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

View File

@ -1185,6 +1185,8 @@ private:
void removeCast14() { // const
// #5081
ASSERT_EQUALS("( ! ( & s ) . a )", tokenizeAndStringify("(! ( (struct S const *) &s)->a)", true));
// #5244
ASSERT_EQUALS("bar ( & ptr ) ;", tokenizeAndStringify("bar((const X**)&ptr);",true));
}
void simplifyFloatCasts() { // float casting integers