Skip to content

Commit 7f62d8f

Browse files
Fix #11594 internalAstError with immediately instantiated enum (#4841)
1 parent 3ec4da0 commit 7f62d8f

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8059,7 +8059,7 @@ void Tokenizer::simplifyStructDecl()
80598059
}
80608060

80618061
if (isEnum) {
8062-
if (tok->next()->str() == "{") {
8062+
if (tok->next()->str() == "{" && tok->next()->link() != tok->tokAt(2)) {
80638063
tok->next()->str("(");
80648064
tok->linkAt(1)->str(")");
80658065
}

test/testsimplifytokens.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,9 +2584,16 @@ class TestSimplifyTokens : public TestFixture {
25842584

25852585
void simplifyVarDeclInitLists()
25862586
{
2587-
const char code[] = "std::vector<int> v{a * b, 1};";
2588-
const char exp[] = "std :: vector < int > v { a * b , 1 } ;";
2589-
ASSERT_EQUALS(exp, tok(code));
2587+
{
2588+
const char code[] = "std::vector<int> v{a * b, 1};";
2589+
const char exp[] = "std :: vector < int > v { a * b , 1 } ;";
2590+
ASSERT_EQUALS(exp, tok(code));
2591+
}
2592+
{
2593+
const char code[] = "enum E { E0 } e{};";
2594+
const char exp[] = "enum E { E0 } ; enum E e ; e = { } ;";
2595+
ASSERT_EQUALS(exp, tok(code));
2596+
}
25902597
}
25912598
};
25922599

0 commit comments

Comments
 (0)