Fixed #1313 (unnamed enums not simplified properly)

This commit is contained in:
Robert Reif 2010-01-25 07:45:16 +01:00 committed by Daniel Marjamäki
parent 989e8393e4
commit 8be8c266ac
2 changed files with 11 additions and 1 deletions

View File

@ -4667,7 +4667,8 @@ void Tokenizer::simplifyEnum()
++classLevel;
continue;
}
else if (Token::Match(tok, "enum %type% {"))
else if (Token::Match(tok, "enum {") ||
Token::Match(tok, "enum %type% {"))
{
Token * tok1;
Token * end;

View File

@ -176,6 +176,7 @@ private:
TEST_CASE(enum1);
TEST_CASE(enum2);
TEST_CASE(enum3);
// remove "std::" on some standard functions
TEST_CASE(removestd);
@ -3138,6 +3139,14 @@ private:
ASSERT_EQUALS(expected, tok(code, false));
}
void enum3()
{
const char code[] = "enum { a, }; int array[a];";
const char expected[] = "enum { a = 0 , } ; int array [ 0 ] ;";
ASSERT_EQUALS(expected, tok(code, false));
}
void removestd()
{
ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));