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:
parent
3b1c9098b8
commit
b2474fd980
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue