diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index ff89f4cc7..b8917e344 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -348,8 +348,10 @@ void CheckClass::createSymbolDatabase() // skip over function body tok = next->next(); - while (tok->str() != "{") + while (tok && tok->str() != "{") tok = tok->next(); + if (!tok) + return; tok = tok->link(); } } diff --git a/test/testclass.cpp b/test/testclass.cpp index 95defe379..433cfc1d1 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -154,6 +154,7 @@ private: TEST_CASE(symboldatabase1); TEST_CASE(symboldatabase2); + TEST_CASE(symboldatabase3); // ticket #2000 } // Check the operator Equal @@ -4278,6 +4279,15 @@ private: "};"); 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)