Merge pull request #194 from simartin/ticket_5121
Ticket #5121: Handle static variable declarations depending on one another
This commit is contained in:
commit
352c459e28
|
@ -5288,9 +5288,9 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, Token * tokEnd, bool only_k_r_
|
|||
|
||||
if (tok2->str() == "=") {
|
||||
if (isstatic) {
|
||||
if (Token::Match(tok2->next(), "%num% ,"))
|
||||
if (Token::Match(tok2->next(), "%num%|%var% ,")) // ticket #5121
|
||||
tok2 = tok2->tokAt(2);
|
||||
else if (Token::Match(tok2->next(), "( %num% ) ,")) { // ticket #4450
|
||||
else if (Token::Match(tok2->next(), "( %num%|%var% ) ,")) { // ticket #4450
|
||||
tok2->deleteNext();
|
||||
tok2->next()->deleteNext();
|
||||
tok2 = tok2->tokAt(2);
|
||||
|
|
|
@ -5670,11 +5670,32 @@ private:
|
|||
}
|
||||
|
||||
{
|
||||
// Ticket #4450
|
||||
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));
|
||||
}
|
||||
|
||||
{
|
||||
// Ticket #5121
|
||||
const char code[] = "unsigned int x;"
|
||||
"static const unsigned int A = 1, B = A, C = 0, D = (A), E = 0;"
|
||||
"void f() {"
|
||||
" unsigned int *foo = &x;"
|
||||
"}";
|
||||
ASSERT_EQUALS("unsigned int x ; "
|
||||
"const static unsigned int A = 1 ; "
|
||||
"const static unsigned int B = A ; "
|
||||
"const static unsigned int C = 0 ; "
|
||||
"const static unsigned int D = A ; "
|
||||
"const static unsigned int E = 0 ; "
|
||||
"void f ( ) { "
|
||||
"unsigned int * foo ; "
|
||||
"foo = & x ; "
|
||||
"}",
|
||||
tokenizeAndStringify(code));
|
||||
}
|
||||
}
|
||||
|
||||
void vardecl6() {
|
||||
|
|
Loading…
Reference in New Issue