Symbol database: fixed problems with namespaces. Ticket: #1895
This commit is contained in:
parent
85acb005a2
commit
cc079462dd
|
@ -70,10 +70,17 @@ void CheckClass::createSymbolDatabase()
|
||||||
new_info->nest = info;
|
new_info->nest = info;
|
||||||
new_info->access = tok->str() == "struct" ? Public : Private;
|
new_info->access = tok->str() == "struct" ? Public : Private;
|
||||||
new_info->numConstructors = 0;
|
new_info->numConstructors = 0;
|
||||||
new_info->getVarList();
|
|
||||||
|
|
||||||
// goto initial '{'
|
const Token *tok2 = tok->tokAt(2);
|
||||||
const Token *tok2 = initBaseInfo(new_info, tok);
|
|
||||||
|
// only create variable list and base list if not namespace
|
||||||
|
if (!new_info->isNamespace)
|
||||||
|
{
|
||||||
|
new_info->getVarList();
|
||||||
|
|
||||||
|
// goto initial '{'
|
||||||
|
tok2 = initBaseInfo(new_info, tok);
|
||||||
|
}
|
||||||
|
|
||||||
new_info->classStart = tok2;
|
new_info->classStart = tok2;
|
||||||
new_info->classEnd = new_info->classStart->link();
|
new_info->classEnd = new_info->classStart->link();
|
||||||
|
@ -339,10 +346,17 @@ const Token *CheckClass::initBaseInfo(SpaceInfo *info, const Token *tok)
|
||||||
{
|
{
|
||||||
// goto initial '{'
|
// goto initial '{'
|
||||||
const Token *tok2 = tok->tokAt(2);
|
const Token *tok2 = tok->tokAt(2);
|
||||||
|
int level = 0;
|
||||||
while (tok2 && tok2->str() != "{")
|
while (tok2 && tok2->str() != "{")
|
||||||
{
|
{
|
||||||
|
// skip unsupported templates
|
||||||
|
if (tok2->str() == "<")
|
||||||
|
level++;
|
||||||
|
else if (tok2->str() == ">")
|
||||||
|
level--;
|
||||||
|
|
||||||
// check for base classes
|
// check for base classes
|
||||||
if (Token::Match(tok2, ":|,"))
|
else if (level == 0 && Token::Match(tok2, ":|,"))
|
||||||
{
|
{
|
||||||
BaseInfo base;
|
BaseInfo base;
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,8 @@ private:
|
||||||
TEST_CASE(constVirtualFunc);
|
TEST_CASE(constVirtualFunc);
|
||||||
TEST_CASE(constIfCfg); // ticket #1881 - fp when there are #if
|
TEST_CASE(constIfCfg); // ticket #1881 - fp when there are #if
|
||||||
TEST_CASE(constFriend); // ticket #1921 - fp for friend function
|
TEST_CASE(constFriend); // ticket #1921 - fp for friend function
|
||||||
|
|
||||||
|
TEST_CASE(symboldatabase1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the operator Equal
|
// Check the operator Equal
|
||||||
|
@ -4196,6 +4198,18 @@ private:
|
||||||
checkConst(code);
|
checkConst(code);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void symboldatabase1()
|
||||||
|
{
|
||||||
|
checkConst("namespace foo {\n"
|
||||||
|
" class bar;\n"
|
||||||
|
"};");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkConst("class foo : public bar < int, int> {\n"
|
||||||
|
"};");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestClass)
|
REGISTER_TEST(TestClass)
|
||||||
|
|
Loading…
Reference in New Issue