aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-12-17 02:04:30 +0000
committerDouglas Gregor <dgregor@apple.com>2008-12-17 02:04:30 +0000
commit45579f5e2904590ff9a4f48c7fbf2e60dccb0426 (patch)
tree38d84a1dd456d9c7fdd1cc30747118cd74da53ff
parente79837aacddb4713465006c0b030bc0675339573 (diff)
Make sure that enumerators show up within the enumeration declaration. Fixes. PR clang/3220
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61116 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Driver/ASTConsumers.cpp7
-rw-r--r--lib/AST/Decl.cpp1
-rw-r--r--lib/Sema/SemaDecl.cpp6
3 files changed, 13 insertions, 1 deletions
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index 4ff8d3cac2..6681ec95f1 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -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)) {
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 4628761de5..dcefaa915b 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -121,7 +121,6 @@ EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
}
void EnumDecl::Destroy(ASTContext& C) {
- DeclContext::DestroyDecls(C);
Decl::Destroy(C);
}
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index b7c83162d6..177bf1a659 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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;
}