Fix const anonymous struct. (#1527)
This commit is contained in:
parent
0f63874c62
commit
1cba78090c
|
@ -8839,7 +8839,7 @@ void Tokenizer::simplifyStructDecl()
|
||||||
Token *restart = next;
|
Token *restart = next;
|
||||||
|
|
||||||
// check for named type
|
// check for named type
|
||||||
if (Token::Match(tok->next(), "*|&| %type% ,|;|[|=|(|{")) {
|
if (Token::Match(tok->next(), "const| *|&| const| %type% ,|;|[|=|(|{")) {
|
||||||
tok->insertToken(";");
|
tok->insertToken(";");
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
while (!Token::Match(start, "struct|class|union|enum")) {
|
while (!Token::Match(start, "struct|class|union|enum")) {
|
||||||
|
|
|
@ -2989,7 +2989,13 @@ private:
|
||||||
|
|
||||||
{
|
{
|
||||||
const char code[] = "struct {int a;} const array[3] = {0};";
|
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));
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue