Fix #11594 internalAstError with immediately instantiated enum (#4841)

This commit is contained in:
chrchr-github 2023-03-02 21:17:39 +01:00 committed by GitHub
parent 3ec4da0f8a
commit 7f62d8ff98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -8059,7 +8059,7 @@ void Tokenizer::simplifyStructDecl()
}
if (isEnum) {
if (tok->next()->str() == "{") {
if (tok->next()->str() == "{" && tok->next()->link() != tok->tokAt(2)) {
tok->next()->str("(");
tok->linkAt(1)->str(")");
}

View File

@ -2583,11 +2583,18 @@ private:
}
void simplifyVarDeclInitLists()
{
{
const char code[] = "std::vector<int> v{a * b, 1};";
const char exp[] = "std :: vector < int > v { a * b , 1 } ;";
ASSERT_EQUALS(exp, tok(code));
}
{
const char code[] = "enum E { E0 } e{};";
const char exp[] = "enum E { E0 } ; enum E e ; e = { } ;";
ASSERT_EQUALS(exp, tok(code));
}
}
};
REGISTER_TEST(TestSimplifyTokens)