Fixed #2000 (segmentation fault of cppcheck with bitfield)

This commit is contained in:
Robert Reif 2010-08-31 17:51:10 +02:00 committed by Daniel Marjamäki
parent 16efc9be26
commit c56911ba6a
2 changed files with 13 additions and 1 deletions

View File

@ -348,8 +348,10 @@ void CheckClass::createSymbolDatabase()
// skip over function body // skip over function body
tok = next->next(); tok = next->next();
while (tok->str() != "{") while (tok && tok->str() != "{")
tok = tok->next(); tok = tok->next();
if (!tok)
return;
tok = tok->link(); tok = tok->link();
} }
} }

View File

@ -154,6 +154,7 @@ private:
TEST_CASE(symboldatabase1); TEST_CASE(symboldatabase1);
TEST_CASE(symboldatabase2); TEST_CASE(symboldatabase2);
TEST_CASE(symboldatabase3); // ticket #2000
} }
// Check the operator Equal // Check the operator Equal
@ -4278,6 +4279,15 @@ private:
"};"); "};");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void symboldatabase3()
{
checkConst("typedef void (func_type)();\n"
"struct A {\n"
" friend func_type f : 2;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
}; };
REGISTER_TEST(TestClass) REGISTER_TEST(TestClass)