diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 21a538946..38e0f588b 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -152,7 +152,7 @@ CheckClass::Var *CheckClass::getVarList(const Token *tok1, bool withClasses, boo // Array? else if (Token::Match(next, "%type% %var% [") && next->next()->str() != "operator") { - if (Token::findmatch(_tokenizer->tokens(), ("class " + next->str()).c_str())) + if (Token::findmatch(_tokenizer->tokens(), ("class|struct " + next->str()).c_str())) continue; varname = next->strAt(1); } diff --git a/test/testclass.cpp b/test/testclass.cpp index 4eaf9ab37..f4972e81e 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -46,6 +46,7 @@ private: TEST_CASE(uninitVar1); TEST_CASE(uninitVar2); + TEST_CASE(uninitVar3); TEST_CASE(uninitVarEnum); TEST_CASE(uninitVarStream); TEST_CASE(uninitVarTypedef); @@ -1107,6 +1108,21 @@ private: ASSERT_EQUALS("", errout.str()); } + void uninitVar3() + { + checkUninitVar("class Foo\n" + "{\n" + "public:\n" + " Foo() { }\n" + "private:\n" + " struct Bar {\n" + " Bar();\n" + " };\n" + " Bar bars[2];\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + } + void uninitVarArray1() { checkUninitVar("class John\n"