Merge branch 'master' of git@github.com:danmar/cppcheck

This commit is contained in:
Kimmo Varis 2009-06-20 23:24:20 +03:00
commit bf84ab4ab2
3 changed files with 65 additions and 7 deletions

View File

@ -441,11 +441,6 @@ void CheckClass::privateFunctions()
{
const std::string &classname = tok1->next()->str();
// The class implementation must be available..
const std::string classconstructor(classname + " :: " + classname);
if (tok1->fileIndex() > 0 && !Token::findmatch(_tokenizer->tokens(), classconstructor.c_str()))
continue;
// Get private functions..
std::list<const Token *> FuncList;
FuncList.clear();

View File

@ -42,7 +42,19 @@ public:
/**
* Tokenize code
* @param code input stream for code
* @param code input stream for code, e.g.
* #file "p.h"
* class Foo
* {
* private:
* void Bar();
* };
*
* #endfile
* void Foo::Bar()
* {
* }
*
* @param FileName The filename
* @return false if Source code contains syntax errors
*/
@ -50,7 +62,7 @@ public:
/**
* Create tokens from code.
* @param code input stream for code
* @param code input stream for code, same as what tokenize()
*/
void createTokens(std::istream &code);

View File

@ -82,6 +82,57 @@ private:
"{ }\n");
ASSERT_EQUALS("[test.cpp:4]: (style) Unused private function 'Fred::f'\n", errout.str());
check("#file \"p.h\"\n"
"class Fred\n"
"{\n"
"private:\n"
" unsigned int f();\n"
"public:\n"
" Fred();\n"
"};\n"
"\n"
"#endfile\n"
"Fred::Fred()\n"
"{ }\n"
"\n"
"unsigned int Fred::f()\n"
"{ }\n");
ASSERT_EQUALS("[p.h:4]: (style) Unused private function 'Fred::f'\n", errout.str());
check("#file \"p.h\"\n"
"class Fred\n"
"{\n"
"private:\n"
"void f();\n"
"};\n"
"\n"
"\n"
"#endfile\n"
"\n"
"void Fred::f()\n"
"{\n"
"}\n"
"\n");
ASSERT_EQUALS("[p.h:4]: (style) Unused private function 'Fred::f'\n", errout.str());
// Don't warn about include files which implementation we don't see
check("#file \"p.h\"\n"
"class Fred\n"
"{\n"
"private:\n"
"void f();\n"
"void g() {}\n"
"};\n"
"\n"
"#endfile\n"
"\n"
"int main()\n"
"{\n"
"}\n"
"\n");
ASSERT_EQUALS("", errout.str());
}