Simplify enum: Fixed segmentation fault if code ends with enum type id
This commit is contained in:
parent
fa493b7fd1
commit
770d2ff835
|
@ -5756,7 +5756,7 @@ void Tokenizer::simplifyEnum()
|
|||
{
|
||||
// Don't replace this enum if it's preceded by "::"
|
||||
}
|
||||
else if (tok2->next()->isName())
|
||||
else if (tok2->next() && tok2->next()->isName())
|
||||
{
|
||||
simplifyEnum = true;
|
||||
hasClass = false;
|
||||
|
|
|
@ -205,6 +205,7 @@ private:
|
|||
TEST_CASE(enum11);
|
||||
TEST_CASE(enum12);
|
||||
TEST_CASE(enum13);
|
||||
TEST_CASE(enum14);
|
||||
|
||||
// remove "std::" on some standard functions
|
||||
TEST_CASE(removestd);
|
||||
|
@ -4008,6 +4009,14 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
}
|
||||
|
||||
void enum14()
|
||||
{
|
||||
const char code[] = "enum ab { a };\n"
|
||||
"ab";
|
||||
const char expected[] = "; ab";
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
}
|
||||
|
||||
void removestd()
|
||||
{
|
||||
ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));
|
||||
|
|
Loading…
Reference in New Issue