#2630 (segmentation fault of cppcheck (template <typedef A>)

This commit is contained in:
Robert Reif 2011-03-18 20:44:58 -04:00
parent 1de35c168d
commit afc7fd82ed
2 changed files with 9 additions and 2 deletions

View File

@ -3449,7 +3449,7 @@ void Tokenizer::setVarId()
{
again = false;
if (tok2->str() == "const")
if (tok2 && tok2->str() == "const")
tok2 = tok2->next();
while (Token::Match(tok2, "%var% ::"))
@ -3484,7 +3484,7 @@ void Tokenizer::setVarId()
{
while (tok2 && (tok2->isName() || tok2->isNumber() || tok2->str() == "*" || tok2->str() == "&" || tok2->str() == ","))
tok2 = tok2->next();
if (tok2->str() == "(")
if (tok2 && tok2->str() == "(")
{
tok2 = tok2->link()->next();
if (tok2->str() == "(")

View File

@ -170,6 +170,7 @@ private:
TEST_CASE(varid25);
TEST_CASE(varid26); // ticket #1967 (list of function pointers)
TEST_CASE(varid27); // Ticket #2280 (same name for namespace and variable)
TEST_CASE(varid28); // ticket #2630
TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2);
TEST_CASE(varidFunctionCall3);
@ -2818,6 +2819,12 @@ private:
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
void varid28() // ticket #2630 (segmentation fault)
{
tokenizeDebugListing("template <typedef A>\n");
ASSERT_EQUALS("", errout.str());
}
void varidFunctionCall1()
{
const std::string code("void f() {\n"