Fix ticket #452 (Failure to detect "member var not initialized in constructor" if class inherits)

http://sourceforge.net/apps/trac/cppcheck/ticket/452
This commit is contained in:
Reijo Tomperi 2009-07-03 21:22:14 +03:00
parent 3b1c9098b8
commit b2474fd980
2 changed files with 13 additions and 1 deletions

View File

@ -262,7 +262,7 @@ void CheckClass::ClassChecking_VarList_Initialize(const Token *tok1, const Token
void CheckClass::constructors()
{
const char pattern_class[] = "class %var% {";
const char pattern_class[] = "class %var% [{:]";
// Locate class
const Token *tok1 = Token::findmatch(_tokenizer->tokens(), pattern_class);

View File

@ -192,6 +192,18 @@ private:
"};\n");
ASSERT_EQUALS("[test.cpp:10]: (style) Member variable not initialized in the constructor 'Fred::_code'\n", errout.str());
checkUninitVar("class A{};\n"
"\n"
"class B : public A\n"
"{\n"
"public:\n"
" B() {}\n"
"private:\n"
" float f;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:6]: (style) Member variable not initialized in the constructor 'B::f'\n", errout.str());
}
void uninitVarEnum()