Fix const anonymous struct. (#1527)

This commit is contained in:
IOBYTE 2018-12-18 02:15:12 -05:00 committed by Daniel Marjamäki
parent 0f63874c62
commit 1cba78090c
2 changed files with 8 additions and 2 deletions

View File

@ -8839,7 +8839,7 @@ void Tokenizer::simplifyStructDecl()
Token *restart = next;
// check for named type
if (Token::Match(tok->next(), "*|&| %type% ,|;|[|=|(|{")) {
if (Token::Match(tok->next(), "const| *|&| const| %type% ,|;|[|=|(|{")) {
tok->insertToken(";");
tok = tok->next();
while (!Token::Match(start, "struct|class|union|enum")) {

View File

@ -2989,7 +2989,13 @@ private:
{
const char code[] = "struct {int a;} const array[3] = {0};";
const char expected[] = "struct Anonymous0 { int a ; } const array [ 3 ] = { 0 } ;";
const char expected[] = "struct Anonymous0 { int a ; } ; struct Anonymous0 const array [ 3 ] = { 0 } ;";
ASSERT_EQUALS(expected, tok(code, false));
}
{
const char code[] = "static struct {int a;} const array[3] = {0};";
const char expected[] = "struct Anonymous0 { int a ; } ; static struct Anonymous0 const array [ 3 ] = { 0 } ;";
ASSERT_EQUALS(expected, tok(code, false));
}