Symbol database: fixed problem

This commit is contained in:
Robert Reif 2010-11-06 20:27:12 +01:00 committed by Daniel Marjamäki
parent 2833a5ebb5
commit 662cd27f87
2 changed files with 41 additions and 2 deletions

View File

@ -185,12 +185,28 @@ void CheckClass::addFunction(SpaceInfo **info, const Token **tok)
else if (func->tokenDef->str() == (*tok)->str()) else if (func->tokenDef->str() == (*tok)->str())
{ {
if (argsMatch(func->tokenDef->next(), (*tok)->next(), path, path_length)) if (argsMatch(func->tokenDef->next(), (*tok)->next(), path, path_length))
{
// normal function?
if (!func->retFuncPtr && (*tok)->next()->link())
{
if ((func->isConst && (*tok)->next()->link()->next()->str() == "const") ||
(!func->isConst && (*tok)->next()->link()->next()->str() != "const"))
{ {
func->hasBody = true; func->hasBody = true;
func->token = (*tok); func->token = (*tok);
} }
} }
// function returning function pointer?
else if (func->retFuncPtr)
{
// todo check for const
func->hasBody = true;
func->token = (*tok);
}
}
}
if (func->hasBody) if (func->hasBody)
{ {
addNewFunction(info, tok); addNewFunction(info, tok);

View File

@ -149,6 +149,7 @@ private:
TEST_CASE(const36); // ticket #2003 TEST_CASE(const36); // ticket #2003
TEST_CASE(const37); // ticket #2081 and #2085 TEST_CASE(const37); // ticket #2081 and #2085
TEST_CASE(const38); // ticket #2135 TEST_CASE(const38); // ticket #2135
TEST_CASE(const39);
TEST_CASE(constoperator1); // operator< can often be const TEST_CASE(constoperator1); // operator< can often be const
TEST_CASE(constoperator2); // operator<< TEST_CASE(constoperator2); // operator<<
TEST_CASE(constoperator3); TEST_CASE(constoperator3);
@ -4368,6 +4369,28 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void const39()
{
checkConst("class Foo\n"
"{\n"
" int * p;\n"
"public:\n"
" Foo () : p(0) { }\n"
" int * f();\n"
" const int * f() const;\n"
"};\n"
"const int * Foo::f() const\n"
"{\n"
" return p;\n"
"}\n"
"int * Foo::f()\n"
"{\n"
" return p;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
// increment/decrement => not const // increment/decrement => not const
void constincdec() void constincdec()
{ {