From 177bf6fcb3ea2ae45baf63288da810803ccea11b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 18 Mar 2014 06:37:19 +0100 Subject: [PATCH] Fixed #5244 (FP: (error) Uninitialized variable: ptr - initialization within if-clause) --- lib/tokenize.cpp | 1 + test/testtokenize.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f07c1d5c3..a5ec03abc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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% * *| *| ) (")))) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 966376b92..9bd022fb0 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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