Fixed #4852 (false positive: Member variable 'A::sz' is not initialized in the constructor)
This commit is contained in:
parent
ae65a47f5f
commit
870d29944b
|
@ -494,8 +494,8 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
|
||||||
assignVar(ftok->strAt(1), scope, usage);
|
assignVar(ftok->strAt(1), scope, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before a new statement there is "[{};)=]"
|
// Before a new statement there is "[{};()=[]"
|
||||||
if (! Token::Match(ftok, "[{};()=]"))
|
if (! Token::Match(ftok, "[{};()=[]"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (Token::simpleMatch(ftok, "( !"))
|
if (Token::simpleMatch(ftok, "( !"))
|
||||||
|
|
|
@ -119,6 +119,7 @@ private:
|
||||||
TEST_CASE(uninitVar23); // ticket #3702
|
TEST_CASE(uninitVar23); // ticket #3702
|
||||||
TEST_CASE(uninitVar24); // ticket #3190
|
TEST_CASE(uninitVar24); // ticket #3190
|
||||||
TEST_CASE(uninitVar25); // ticket #4789
|
TEST_CASE(uninitVar25); // ticket #4789
|
||||||
|
TEST_CASE(uninitVar26);
|
||||||
TEST_CASE(uninitVarEnum);
|
TEST_CASE(uninitVarEnum);
|
||||||
TEST_CASE(uninitVarStream);
|
TEST_CASE(uninitVarStream);
|
||||||
TEST_CASE(uninitVarTypedef);
|
TEST_CASE(uninitVarTypedef);
|
||||||
|
@ -1890,6 +1891,19 @@ private:
|
||||||
"[test.cpp:42]: (warning) Member variable 'F::c' is not initialized in the constructor.\n", errout.str());
|
"[test.cpp:42]: (warning) Member variable 'F::c' is not initialized in the constructor.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uninitVar26()
|
||||||
|
{
|
||||||
|
check("class A {\n"
|
||||||
|
" int * v;\n"
|
||||||
|
" int sz;\n"
|
||||||
|
"public:\n"
|
||||||
|
" A(int s) {\n"
|
||||||
|
" v = new int [sz = s];\n"
|
||||||
|
" }\n"
|
||||||
|
"};");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void uninitVarArray1() {
|
void uninitVarArray1() {
|
||||||
check("class John\n"
|
check("class John\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue