Fixed #2539 (segmentation fault of cppcheck)

This commit is contained in:
Robert Reif 2011-02-04 20:19:49 +01:00 committed by Daniel Marjamäki
parent 514c9b9b23
commit f87056fca3
2 changed files with 15 additions and 1 deletions

View File

@ -581,7 +581,9 @@ bool SymbolDatabase::isFunction(const Token *tok, const Token **funcStart, const
}
// regular function?
else if (Token::Match(tok, "%var% (") && Token::Match(tok->next()->link(), ") const| ;|{|=|:"))
else if (Token::Match(tok, "%var% (") &&
(Token::Match(tok->next()->link(), ") const| ;|{|=") ||
Token::Match(tok->next()->link(), ") : %var% (")))
{
*funcStart = tok;
*argStart = tok->next();

View File

@ -189,6 +189,7 @@ private:
TEST_CASE(symboldatabase8); // ticket #2252
TEST_CASE(symboldatabase9); // ticket #2525
TEST_CASE(symboldatabase10); // ticket #2537
TEST_CASE(symboldatabase11); // ticket #2539
}
// Check the operator Equal
@ -5505,6 +5506,17 @@ private:
ASSERT_EQUALS("", errout.str());
}
void symboldatabase11()
{
// ticket #2539 - segmentation fault
checkConst("int g ();\n"
"struct S {\n"
" int i : (false ? g () : 1);\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestClass)