#2560 (False positive: The class 'Altren' does not have a constructor, because base class is in namespace.)

This commit is contained in:
Robert Reif 2011-02-10 07:37:55 -05:00
parent e6848aef98
commit 2900d44ff0
2 changed files with 19 additions and 1 deletions

View File

@ -583,7 +583,7 @@ bool SymbolDatabase::isFunction(const Token *tok, const Token **funcStart, const
// regular function?
else if (Token::Match(tok, "%var% (") &&
(Token::Match(tok->next()->link(), ") const| ;|{|=") ||
Token::Match(tok->next()->link(), ") : %var% (")))
Token::Match(tok->next()->link(), ") : %var% (|::")))
{
*funcStart = tok;
*argStart = tok->next();

View File

@ -60,6 +60,7 @@ private:
TEST_CASE(simple2);
TEST_CASE(simple3);
TEST_CASE(simple4);
TEST_CASE(simple5); // ticket #2560
TEST_CASE(initvar_with_this); // BUG 2190300
TEST_CASE(initvar_if); // BUG 2190290
@ -258,6 +259,23 @@ private:
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
}
void simple5() // ticket #2560
{
check("namespace Nsp\n"
"{\n"
" class B { };\n"
"}\n"
"class Altren : public Nsp::B\n"
"{\n"
"public:\n"
" Altren () : Nsp::B(), mValue(0)\n"
" {\n"
" }\n"
"private:\n"
" int mValue;\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void initvar_with_this()
{