Make sure that enumerators show up within the enumeration declaration. Fixes. PR clang/3220

llvm-svn: 61116
This commit is contained in:
Douglas Gregor 2008-12-17 02:04:30 +00:00
parent 89da43922b
commit 2f52119843
3 changed files with 13 additions and 1 deletions

View File

@ -107,6 +107,13 @@ void DeclPrinter:: PrintDecl(Decl *D) {
Out << D->getNameAsString();
}
Out << ";\n";
} else if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
Out << "enum " << ED->getNameAsString() << " {\n";
for (EnumDecl::enumerator_iterator E = ED->enumerator_begin(),
EEnd = ED->enumerator_end();
E != EEnd; ++E)
Out << " " << (*E)->getNameAsString() << ",\n";
Out << "};\n";
} else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
Out << "Read top-level tag decl: '" << TD->getNameAsString() << "'\n";
} else if (ScopedDecl *SD = dyn_cast<ScopedDecl>(D)) {

View File

@ -121,7 +121,6 @@ EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
}
void EnumDecl::Destroy(ASTContext& C) {
DeclContext::DestroyDecls(C);
Decl::Destroy(C);
}

View File

@ -3185,6 +3185,12 @@ Sema::DeclTy *Sema::ActOnEnumConstant(Scope *S, DeclTy *theEnumDecl,
// Register this decl in the current scope stack.
PushOnScopeChains(New, S);
// Add this enumerator into the enum itself.
// FIXME: This means that the enumerator is stored in two
// DeclContexts. This is not a long-term solution.
New->setLexicalDeclContext(TheEnumDecl);
TheEnumDecl->addDecl(Context, New, true);
return New;
}