parent
d43cd56afd
commit
915acac0b8
|
@ -170,7 +170,8 @@ void CheckUninitVar::checkStruct(const Token *tok, const Variable &structvar)
|
|||
for (std::list<Variable>::const_iterator it = scope2->varlist.begin(); it != scope2->varlist.end(); ++it) {
|
||||
const Variable &var = *it;
|
||||
|
||||
if (var.hasDefault() || var.isArray() || (!mTokenizer->isC() && var.isClass() && (!var.type() || var.type()->needInitialization != Type::True)))
|
||||
if (var.isStatic() || var.hasDefault() || var.isArray() ||
|
||||
(!mTokenizer->isC() && var.isClass() && (!var.type() || var.type()->needInitialization != Type::True)))
|
||||
continue;
|
||||
|
||||
// is the variable declared in a inner union?
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
TEST_CASE(uninitvar_pointertoarray);
|
||||
TEST_CASE(uninitvar_cpp11ArrayInit); // #7010
|
||||
TEST_CASE(uninitvar_rangeBasedFor); // #7078
|
||||
TEST_CASE(uninitvar_static); // #8734
|
||||
TEST_CASE(trac_4871);
|
||||
TEST_CASE(syntax_error); // Ticket #5073
|
||||
TEST_CASE(trac_5970);
|
||||
|
@ -3811,6 +3812,21 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitvar_static() { // #8734
|
||||
checkUninitVar("struct X { "
|
||||
" typedef struct { int p; } P_t; "
|
||||
" static int arr[]; "
|
||||
"}; "
|
||||
"int X::arr[] = {42}; "
|
||||
"void f() { "
|
||||
" std::vector<X::P_t> result; "
|
||||
" X::P_t P; "
|
||||
" P.p = 0; "
|
||||
" result.push_back(P); "
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void trac_4871() { // #4871
|
||||
checkUninitVar("void pickup(int a) {\n"
|
||||
"bool using_planner_action;\n"
|
||||
|
|
Loading…
Reference in New Issue