Symbol database: fixed false negative for uninitialized variable. ticket: #1895
This commit is contained in:
parent
80be31de13
commit
c3762903a9
|
@ -1020,10 +1020,7 @@ bool CheckClass::argsMatch(const Token *first, const Token *second, const std::s
|
||||||
|
|
||||||
// skip default value assignment
|
// skip default value assignment
|
||||||
else if (first->next()->str() == "=")
|
else if (first->next()->str() == "=")
|
||||||
{
|
|
||||||
first = first->tokAt(2);
|
first = first->tokAt(2);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// definition missing variable name
|
// definition missing variable name
|
||||||
else if (first->next()->str() == "," && second->next()->str() != ",")
|
else if (first->next()->str() == "," && second->next()->str() != ",")
|
||||||
|
@ -1173,7 +1170,7 @@ void CheckClass::constructors()
|
||||||
if (classNameUsed)
|
if (classNameUsed)
|
||||||
operatorEqVarError(it->token, info->className, var->token->str());
|
operatorEqVarError(it->token, info->className, var->token->str());
|
||||||
}
|
}
|
||||||
else if (it->access != Private && !var->isStatic)
|
else if (it->access != Private)
|
||||||
uninitVarError(it->token, info->className, var->token->str());
|
uninitVarError(it->token, info->className, var->token->str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ private:
|
||||||
TEST_CASE(uninitVar8);
|
TEST_CASE(uninitVar8);
|
||||||
TEST_CASE(uninitVar9); // ticket #1730
|
TEST_CASE(uninitVar9); // ticket #1730
|
||||||
TEST_CASE(uninitVar10); // ticket #1993
|
TEST_CASE(uninitVar10); // ticket #1993
|
||||||
|
TEST_CASE(uninitVar11);
|
||||||
TEST_CASE(uninitVarEnum);
|
TEST_CASE(uninitVarEnum);
|
||||||
TEST_CASE(uninitVarStream);
|
TEST_CASE(uninitVarStream);
|
||||||
TEST_CASE(uninitVarTypedef);
|
TEST_CASE(uninitVarTypedef);
|
||||||
|
@ -1645,6 +1646,18 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:8]: (style) Member variable not initialized in the constructor 'A::var2'\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:8]: (style) Member variable not initialized in the constructor 'A::var2'\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uninitVar11()
|
||||||
|
{
|
||||||
|
checkUninitVar("class A {\n"
|
||||||
|
"public:\n"
|
||||||
|
" A(int a = 0);\n"
|
||||||
|
"private:\n"
|
||||||
|
" int var;\n"
|
||||||
|
"};\n"
|
||||||
|
"A::A(int a) { }\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:7]: (style) Member variable not initialized in the constructor 'A::var'\n", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void uninitVarArray1()
|
void uninitVarArray1()
|
||||||
{
|
{
|
||||||
checkUninitVar("class John\n"
|
checkUninitVar("class John\n"
|
||||||
|
|
Loading…
Reference in New Issue