Fixed #1221 ([False positive] Member variable not initialized with operator[] gives wrong result)
This commit is contained in:
parent
0010a98316
commit
485f3c7708
|
@ -165,7 +165,7 @@ CheckClass::Var *CheckClass::getVarList(const Token *tok1, bool withClasses, boo
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the varname was set in one of the two if-block above, create a entry for this variable..
|
// If the varname was set in one of the two if-block above, create a entry for this variable..
|
||||||
if (varname)
|
if (varname && strcmp(varname, "operator"))
|
||||||
{
|
{
|
||||||
Var *var = new Var(varname, false, priv, varlist);
|
Var *var = new Var(varname, false, priv, varlist);
|
||||||
varlist = var;
|
varlist = var;
|
||||||
|
|
|
@ -59,6 +59,7 @@ private:
|
||||||
TEST_CASE(uninitVarHeader2); // Class is defined in header
|
TEST_CASE(uninitVarHeader2); // Class is defined in header
|
||||||
TEST_CASE(uninitVarHeader3); // Class is defined in header
|
TEST_CASE(uninitVarHeader3); // Class is defined in header
|
||||||
TEST_CASE(uninitVarPublished); // Variables in the published section are auto-initialized
|
TEST_CASE(uninitVarPublished); // Variables in the published section are auto-initialized
|
||||||
|
TEST_CASE(uninitOperator); // No FP about uninitialized 'operator[]'
|
||||||
|
|
||||||
TEST_CASE(noConstructor1);
|
TEST_CASE(noConstructor1);
|
||||||
TEST_CASE(noConstructor2);
|
TEST_CASE(noConstructor2);
|
||||||
|
@ -1213,7 +1214,16 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uninitOperator()
|
||||||
|
{
|
||||||
|
checkUninitVar("class Fred\n"
|
||||||
|
"{\n"
|
||||||
|
"public:\n"
|
||||||
|
" Fred() { }\n"
|
||||||
|
" int *operator [] (int index) { return 0; }\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void checkNoConstructor(const char code[])
|
void checkNoConstructor(const char code[])
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue