]> granicus.if.org Git - clang/commitdiff
Make sure that enumerators show up within the enumeration declaration. Fixes. PR...
authorDouglas Gregor <dgregor@apple.com>
Wed, 17 Dec 2008 02:04:30 +0000 (02:04 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 17 Dec 2008 02:04:30 +0000 (02:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61116 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/ASTConsumers.cpp
lib/AST/Decl.cpp
lib/Sema/SemaDecl.cpp

index 4ff8d3cac23e3c5ecb6b750bfd6ff4a776780e8d..6681ec95f1a47c827c275c37ebd0ee58254e96e0 100644 (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)) {
index 4628761de59587b1cdad960f6555e37aae353402..dcefaa915b7b964891e33a7d6ef5bae5d4fc8dd4 100644 (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);
 }
 
index b7c83162d69fa62222bfe78a6cd109394ce9e473..177bf1a65955fdfb0f3edd6a8ae36a9a32bda669 100644 (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;
 }