Fixed #2464 (False positive: not initialised/not assigned Static variable in copy constructors.)

This commit is contained in:
Robert Reif 2011-01-15 08:04:50 +01:00 committed by Daniel Marjamäki
parent 79b9939610
commit 8ecba0af90
2 changed files with 14 additions and 0 deletions

View File

@ -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());
}

View File

@ -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()