Ticket #4450: Handle comma separated static variable declarations with initializers in brackets.

This commit is contained in:
Simon Martin 2013-08-24 22:27:54 +02:00
parent a70b0cd0f3
commit b713a69b30
2 changed files with 12 additions and 1 deletions

View File

@ -5244,7 +5244,11 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, Token * tokEnd, bool only_k_r_
if (isstatic) { if (isstatic) {
if (Token::Match(tok2->next(), "%num% ,")) if (Token::Match(tok2->next(), "%num% ,"))
tok2 = tok2->tokAt(2); tok2 = tok2->tokAt(2);
else else if (Token::Match(tok2->next(), "( %num% ) ,")) { // ticket #4450
tok2->deleteNext();
tok2->next()->deleteNext();
tok2 = tok2->tokAt(2);
} else
tok2 = NULL; tok2 = NULL;
} else if (isconst && !ispointer) { } else if (isconst && !ispointer) {
//do not split const non-pointer variables.. //do not split const non-pointer variables..

View File

@ -5581,6 +5581,13 @@ private:
const char code[] = "static unsigned int *a=0, *b=0;"; const char code[] = "static unsigned int *a=0, *b=0;";
ASSERT_EQUALS("static unsigned int * a = 0 ; static unsigned int * b = 0 ;", tokenizeAndStringify(code)); ASSERT_EQUALS("static unsigned int * a = 0 ; static unsigned int * b = 0 ;", tokenizeAndStringify(code));
} }
{
const char code[] = "static int large_eeprom_type = (13 | (5)), "
"default_flash_type = 42;";
ASSERT_EQUALS("static int large_eeprom_type = 13 ; static int default_flash_type = 42 ;",
tokenizeAndStringify(code));
}
} }
void vardecl6() { void vardecl6() {