Fixed #1342 (Superclass constructors in initializer lists are considered unused functions when superclass has a namespace.)

This commit is contained in:
Daniel Marjamäki 2010-02-03 18:37:48 +01:00
parent f2eac901c0
commit b01af012cd
2 changed files with 17 additions and 1 deletions

View File

@ -53,8 +53,15 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer)
if (tok->fileIndex() != 0)
continue;
// token contains a ':' => skip to next ; or {
if (tok->str().find(":") != std::string::npos)
continue;
{
while (tok && tok->str().find_first_of(";{"))
tok = tok->next();
if (tok)
continue;
break;
}
// If this is a template function, skip it
if (tok->previous() && tok->previous()->str() == ">")

View File

@ -44,6 +44,7 @@ private:
TEST_CASE(template1);
TEST_CASE(throwIsNotAFunction);
TEST_CASE(unusedError);
TEST_CASE(initializationIsNotAFunction);
}
void check(const char code[])
@ -170,6 +171,14 @@ private:
"int main()\n");
ASSERT_EQUALS("[test.cpp:1]: (style) The function 'foo' is never used\n", errout.str());
}
void initializationIsNotAFunction()
{
check("struct B: N::A {\n"
" B(): N::A() {};\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestUnusedFunctions)