Fix typedef in enum class (#4998)

This commit is contained in:
chrchr-github 2023-04-21 18:58:44 +02:00 committed by GitHub
parent 89b47e725f
commit bda9f707cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -1802,7 +1802,7 @@ void Tokenizer::simplifyTypedefCpp()
}
}
simplifyType = simplifyType && !inEnumClass;
simplifyType = simplifyType && (!inEnumClass || Token::simpleMatch(tok2->previous(), "="));
if (simplifyType) {
mTypedefInfo.back().used = true;

View File

@ -3224,6 +3224,14 @@ private:
"enum class E { A };\n";
ASSERT_EQUALS("enum class E { A } ;", tok(code));
}
{
const char code[] = "namespace N {\n"
" struct S { enum E { E0 }; };\n"
"}\n"
"typedef N::S T;\n"
"enum class E { a = T::E0; };\n";
ASSERT_EQUALS("namespace N { struct S { enum E { E0 } ; } ; } enum class E { a = N :: S :: E0 ; } ;", tok(code));
}
{ // #11494
const char code[] = "typedef struct S {} KEY;\n"
"class C { enum E { KEY }; };\n";