diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index 87a5b605..581108a1 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -1714,14 +1714,34 @@ CppSharp::AST::Enumeration^ Parser::WalkEnum(clang::EnumDecl* ED) assert(NS && "Expected a valid namespace"); auto Name = marshalString(GetTagDeclName(ED)); - auto E = NS->FindEnum(Name, /*Create=*/false); + CppSharp::AST::Enumeration^ E = nullptr; + if (!System::String::IsNullOrEmpty(Name)) + E = NS->FindEnum(Name, /*Create=*/false); + else + { + // Enum with no identifier - try to find existing enum through enum items + for (auto it = ED->enumerator_begin(); it != ED->enumerator_end(); ++it) + { + EnumConstantDecl* ECD = (*it); + auto EnumItemName = marshalString(ECD->getNameAsString()); + E = NS->FindEnumWithItem(EnumItemName); + break; + } + } if (E && !E->IsIncomplete) return E; if (!E) { - E = NS->FindEnum(Name, /*Create=*/true); + if (!System::String::IsNullOrEmpty(Name)) + E = NS->FindEnum(Name, /*Create=*/true); + else + { + E = gcnew CppSharp::AST::Enumeration(); + E->Namespace = NS; + NS->Enums->Add(E); + } HandleDeclaration(ED, E); }