Support C++11 array initialization in CheckUninitVar (#7010)

This commit is contained in:
PKEuS 2015-10-24 12:06:40 +02:00
parent 0825c57c9f
commit e989d4b11b
2 changed files with 10 additions and 1 deletions

View File

@ -78,7 +78,7 @@ void CheckUninitVar::checkScope(const Scope* scope)
tok = tok->next();
while (Token::simpleMatch(tok->link(), "] ["))
tok = tok->link()->next();
if (Token::simpleMatch(tok->link(), "] ="))
if (Token::Match(tok->link(), "] =|{"))
continue;
}

View File

@ -67,6 +67,7 @@ private:
TEST_CASE(uninitvar_operator); // #6680
TEST_CASE(uninitvar_ternaryexpression); // #4683
TEST_CASE(uninitvar_pointertoarray);
TEST_CASE(uninitvar_cpp11ArrayInit); // #7010
TEST_CASE(trac_4871);
TEST_CASE(syntax_error); // Ticket #5073
@ -1480,6 +1481,14 @@ private:
errout.str());
}
void uninitvar_cpp11ArrayInit() { // #7010
checkUninitVar("double foo(bool flag) {\n"
" double adIHPoint_local[4][4]{};\n"
" function(*adIHPoint_local);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
// alloc..
void uninitvar_alloc() {
checkUninitVar("void f() {\n"