fix #2966 (segmentation fault of cppcheck ( enum x : ))

This commit is contained in:
Robert Reif 2011-08-05 18:07:18 -04:00
parent fd7e085c9d
commit fd01a7555a
2 changed files with 15 additions and 0 deletions

View File

@ -8227,6 +8227,13 @@ void Tokenizer::simplifyEnum()
if (tok->next()->str() == ":")
{
tok = tok->next();
if (!tok->next())
{
syntaxError(tok);
return;
}
typeTokenStart = tok->next();
tok = tok->next();
typeTokenEnd = typeTokenStart;

View File

@ -312,6 +312,7 @@ private:
TEST_CASE(enum22); // ticket #2745
TEST_CASE(enum23); // ticket #2804
TEST_CASE(enum24); // ticket #2828
TEST_CASE(enum25); // ticket #2966
// remove "std::" on some standard functions
TEST_CASE(removestd);
@ -6648,6 +6649,13 @@ private:
ASSERT_EQUALS("", errout.str());
}
void enum25() // ticket #2966 (segmentation fault)
{
const char code[] = "enum x :\n";
tok(code, false);
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
}
void removestd()
{
ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));