Symbol database: Fixed bug when end of namespace wasn't found. Ticket: #1895

This commit is contained in:
Robert Reif 2010-08-14 08:16:53 +02:00 committed by Daniel Marjamäki
parent 6efad92647
commit 7c18ece65d
2 changed files with 18 additions and 4 deletions

View File

@ -85,15 +85,17 @@ void CheckClass::createSymbolDatabase()
tok = tok2;
}
// check if in class
else if (info && !info->isNamespace)
// check if in space
else if (info)
{
// check for end of class
// check for end of space
if (tok == info->classEnd)
{
info = info->nest;
}
else
// check if in class or structure
else if (!info->isNamespace)
{
// What section are we in..
if (tok->str() == "private:")

View File

@ -135,6 +135,7 @@ private:
TEST_CASE(const28); // ticket #1883
TEST_CASE(const29); // ticket #1922
TEST_CASE(const30);
TEST_CASE(const31);
TEST_CASE(constoperator1); // operator< can often be const
TEST_CASE(constoperator2); // operator<<
TEST_CASE(constincdec); // increment/decrement => non-const
@ -3852,6 +3853,17 @@ private:
ASSERT_EQUALS("", errout.str());
}
void const31()
{
checkConst("namespace std { }\n"
"class Fred {\n"
"public:\n"
" int a;\n"
" int get() { return a; }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:5]: (style) The function 'Fred::get' can be const\n", errout.str());
}
// increment/decrement => not const
void constincdec()
{