Fixed #2178 (segmentation fault of cppcheck)

This commit is contained in:
Daniel Marjamäki 2010-11-08 19:47:19 +01:00
parent 6a4f70e496
commit c2bf3647a4
2 changed files with 22 additions and 0 deletions

View File

@ -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<SpaceInfo *>::iterator it;

View File

@ -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)