Fixed ticket #459 (false positive::Member variable not initialized in constructor)
http://sourceforge.net/apps/trac/cppcheck/ticket/459
This commit is contained in:
parent
7df3670128
commit
5dea30519c
|
@ -381,7 +381,7 @@ void CheckClass::checkConstructors(const Token *tok1, const char funcname[])
|
||||||
|
|
||||||
// Is it a static member variable?
|
// Is it a static member variable?
|
||||||
std::ostringstream pattern;
|
std::ostringstream pattern;
|
||||||
pattern << className << "::" << var->name << "=";
|
pattern << className << " :: " << var->name << " =";
|
||||||
if (Token::findmatch(_tokenizer->tokens(), pattern.str().c_str()))
|
if (Token::findmatch(_tokenizer->tokens(), pattern.str().c_str()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,19 @@ private:
|
||||||
" float f;\n"
|
" float f;\n"
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("[test.cpp:6]: (style) Member variable not initialized in the constructor 'B::f'\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:6]: (style) Member variable not initialized in the constructor 'B::f'\n", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("class C\n"
|
||||||
|
"{\n"
|
||||||
|
" FILE *fp;\n"
|
||||||
|
"\n"
|
||||||
|
"public:\n"
|
||||||
|
" C(FILE *fp);\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"C::C(FILE *fp) {\n"
|
||||||
|
" C::fp = fp;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitVarEnum()
|
void uninitVarEnum()
|
||||||
|
|
Loading…
Reference in New Issue