Fixed #2464 (False positive: not initialised/not assigned Static variable in copy constructors.)
This commit is contained in:
parent
79b9939610
commit
8ecba0af90
|
@ -8668,6 +8668,7 @@ void Tokenizer::simplifyStructDecl()
|
|||
// check for named struct/union
|
||||
if (Token::Match(tok, "struct|union %type% :|{"))
|
||||
{
|
||||
Token *isStatic = tok->previous() && tok->previous()->str() == "static" ? tok->previous() : NULL;
|
||||
Token *type = tok->next();
|
||||
Token *next = tok->tokAt(2);
|
||||
|
||||
|
@ -8684,6 +8685,12 @@ void Tokenizer::simplifyStructDecl()
|
|||
{
|
||||
tok->insertToken(";");
|
||||
tok = tok->next();
|
||||
if (isStatic)
|
||||
{
|
||||
isStatic->deleteThis();
|
||||
tok->insertToken("static");
|
||||
tok = tok->next();
|
||||
}
|
||||
tok->insertToken(type->str().c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -6271,6 +6271,13 @@ private:
|
|||
const char expected[] = ";";
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
}
|
||||
|
||||
// ticket 2464
|
||||
{
|
||||
const char code[] = "static struct ABC { } abc ;";
|
||||
const char expected[] = "struct ABC { } ; static ABC abc ;";
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
}
|
||||
}
|
||||
|
||||
void removeUnwantedKeywords()
|
||||
|
|
Loading…
Reference in New Issue