Fixed #1342 (Superclass constructors in initializer lists are considered unused functions when superclass has a namespace.)
This commit is contained in:
parent
f2eac901c0
commit
b01af012cd
|
@ -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() == ">")
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue