diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7e485f859..f9a9d9603 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1802,7 +1802,7 @@ void Tokenizer::simplifyTypedefCpp() } } - simplifyType = simplifyType && !inEnumClass; + simplifyType = simplifyType && (!inEnumClass || Token::simpleMatch(tok2->previous(), "=")); if (simplifyType) { mTypedefInfo.back().used = true; diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 4e9b95915..fc33210c6 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -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";