Class checking: Fixed FP for static arrays (not initialized in constructor)
This commit is contained in:
parent
4668359b51
commit
76133e0234
|
@ -104,19 +104,23 @@ CheckClass::Var *CheckClass::getVarList(const Token *tok1, bool withClasses, boo
|
|||
if (next->str() == "__property")
|
||||
continue;
|
||||
|
||||
// Is it a static variable?
|
||||
bool isStatic = false;
|
||||
if (next->str() == "static")
|
||||
// Is it const..?
|
||||
if (next->str() == "const")
|
||||
{
|
||||
next = next->next();
|
||||
}
|
||||
|
||||
// Is it a static variable?
|
||||
const bool isStatic(Token::simpleMatch(next, "static"));
|
||||
if (isStatic)
|
||||
{
|
||||
isStatic = true;
|
||||
next = next->next();
|
||||
}
|
||||
|
||||
// Is it a mutable variable?
|
||||
bool isMutable = false;
|
||||
if (next->str() == "mutable")
|
||||
const bool isMutable(Token::simpleMatch(next, "mutable"));
|
||||
if (isMutable)
|
||||
{
|
||||
isMutable = true;
|
||||
next = next->next();
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ private:
|
|||
TEST_CASE(uninitVarArray3);
|
||||
TEST_CASE(uninitVarArray4);
|
||||
TEST_CASE(uninitVarArray5);
|
||||
TEST_CASE(uninitVarArray6);
|
||||
TEST_CASE(uninitVarArray2D);
|
||||
TEST_CASE(uninitMissingFuncDef);// can't expand function in constructor
|
||||
TEST_CASE(privateCtor1); // If constructor is private..
|
||||
|
@ -1702,6 +1703,19 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitVarArray6()
|
||||
{
|
||||
checkUninitVar("class Foo\n"
|
||||
"{\n"
|
||||
"public:\n"
|
||||
" Foo();\n"
|
||||
" static const char STR[];\n"
|
||||
"};\n"
|
||||
"const char Foo::STR[] = \"abc\";\n"
|
||||
"Foo::Foo() { }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitVarArray2D()
|
||||
{
|
||||
checkUninitVar("class John\n"
|
||||
|
|
Loading…
Reference in New Issue