fix #2595 bitfield fix for case x: break; and default: break;

This commit is contained in:
Robert Reif 2011-02-28 19:35:00 -05:00
parent 893b84a87c
commit 92efbd748e
2 changed files with 10 additions and 2 deletions

View File

@ -9124,7 +9124,8 @@ void Tokenizer::simplifyBitfields()
{
Token *last = 0;
if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% %var% : %any% ;|,"))
if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% %var% : %any% ;|,") &&
tok->next()->str() != "case")
{
int offset = 0;
if (tok->next()->str() == "const")
@ -9133,7 +9134,8 @@ void Tokenizer::simplifyBitfields()
last = tok->tokAt(5 + offset);
Token::eraseTokens(tok->tokAt(2 + offset), tok->tokAt(5 + offset));
}
else if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% : %any% ;"))
else if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% : %any% ;") &&
tok->next()->str() != "default")
{
int offset = 0;
if (tok->next()->str() == "const")

View File

@ -5121,6 +5121,12 @@ private:
const char code3[] = "struct A { bool : true; };";
ASSERT_EQUALS("struct A { } ;", tokenizeAndStringify(code3,false));
const char code4[] = "void f(int a) { switch (a) { case b: break; } }";
ASSERT_EQUALS("void f ( int a ) { switch ( a ) { case b : ; break ; } }", tokenizeAndStringify(code4,true));
const char code5[] = "void f(int a) { switch (a) { default: break; } }";
ASSERT_EQUALS("void f ( int a ) { switch ( a ) { default : ; break ; } }", tokenizeAndStringify(code5,true));
}
void microsoftMFC()