diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index bf6903d38..df349f32b 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -499,7 +499,19 @@ void CheckClass::createSymbolDatabase() // not in SpaceInfo else + { + // found a "?" skip until the end of statement is found to avoid detecting + // false functions.. + if (tok->str() == "?") + { + while (tok && !Token::Match(tok, "[;{}]")) + tok = tok->next(); + if (!tok) + break; + } + addIfFunction(&info, &tok); + } } std::list::iterator it; diff --git a/test/testclass.cpp b/test/testclass.cpp index eb6c66e63..4d9489c04 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -167,6 +167,7 @@ private: TEST_CASE(symboldatabase2); TEST_CASE(symboldatabase3); // ticket #2000 TEST_CASE(symboldatabase4); + TEST_CASE(symboldatabase5); // ticket #2178 } // Check the operator Equal @@ -4796,6 +4797,15 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); } + + void symboldatabase5() + { + // ticket #2178 - segmentation fault + checkConst("int CL_INLINE_DECL(integer_decode_float) (int x) {\n" + " return (sign ? cl_I() : 0);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestClass)