Pass access specifiers through to member classes and member enums.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67710 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index a6e7d52..7a92171 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -471,7 +471,8 @@
 /// [C++]   'explicit'
 ///
 void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
-                                        TemplateParameterLists *TemplateParams){
+                                        TemplateParameterLists *TemplateParams,
+                                        AccessSpecifier AS){
   DS.SetRangeStart(Tok.getLocation());
   while (1) {
     int isInvalid = false;
@@ -767,12 +768,12 @@
     case tok::kw_class:
     case tok::kw_struct:
     case tok::kw_union:
-      ParseClassSpecifier(DS, TemplateParams);
+      ParseClassSpecifier(DS, TemplateParams, AS);
       continue;
 
     // enum-specifier:
     case tok::kw_enum:
-      ParseEnumSpecifier(DS);
+      ParseEnumSpecifier(DS, AS);
       continue;
 
     // cv-qualifier:
@@ -1228,7 +1229,7 @@
 /// [C++] elaborated-type-specifier:
 /// [C++]   'enum' '::'[opt] nested-name-specifier[opt] identifier
 ///
-void Parser::ParseEnumSpecifier(DeclSpec &DS) {
+void Parser::ParseEnumSpecifier(DeclSpec &DS, AccessSpecifier AS) {
   assert(Tok.is(tok::kw_enum) && "Not an enum specifier");
   SourceLocation StartLoc = ConsumeToken();
   
@@ -1285,7 +1286,7 @@
   else
     TK = Action::TK_Reference;
   DeclTy *TagDecl = Actions.ActOnTag(CurScope, DeclSpec::TST_enum, TK, StartLoc,
-                                     SS, Name, NameLoc, Attr);
+                                     SS, Name, NameLoc, Attr, AS);
   
   if (Tok.is(tok::l_brace))
     ParseEnumBody(StartLoc, TagDecl);
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index d2d8c1e..1bbf411 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -349,7 +349,8 @@
 ///         'struct'
 ///         'union'
 void Parser::ParseClassSpecifier(DeclSpec &DS,
-                                 TemplateParameterLists *TemplateParams) {
+                                 TemplateParameterLists *TemplateParams,
+                                 AccessSpecifier AS) {
   assert((Tok.is(tok::kw_class) || 
           Tok.is(tok::kw_struct) || 
           Tok.is(tok::kw_union)) &&
@@ -462,7 +463,7 @@
                                                       TemplateParams->size()));
   else
     TagOrTempResult = Actions.ActOnTag(CurScope, TagType, TK, StartLoc, SS, Name, 
-                                     NameLoc, Attr);
+                                       NameLoc, Attr, AS);
 
   // Parse the optional base clause (C++ only).
   if (getLang().CPlusPlus && Tok.is(tok::colon))
@@ -649,7 +650,7 @@
   // decl-specifier-seq:
   // Parse the common declaration-specifiers piece.
   DeclSpec DS;
-  ParseDeclarationSpecifiers(DS);
+  ParseDeclarationSpecifiers(DS, 0, AS);
 
   if (Tok.is(tok::semi)) {
     ConsumeToken();
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index ad7aa3b..8c1b78c 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -390,7 +390,7 @@
   virtual DeclTy *ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
                            SourceLocation KWLoc, const CXXScopeSpec &SS,
                            IdentifierInfo *Name, SourceLocation NameLoc,
-                           AttributeList *Attr);
+                           AttributeList *Attr, AccessSpecifier AS);
   
   virtual void ActOnDefs(Scope *S, DeclTy *TagD, SourceLocation DeclStart,
                          IdentifierInfo *ClassName,
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index cc1a5b3..a2ec938 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3068,7 +3068,7 @@
 Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
                              SourceLocation KWLoc, const CXXScopeSpec &SS,
                              IdentifierInfo *Name, SourceLocation NameLoc,
-                             AttributeList *Attr) {
+                             AttributeList *Attr, AccessSpecifier AS) {
   // If this is not a definition, it must have a name.
   assert((Name != 0 || TK == TK_Definition) &&
          "Nameless record must be a definition!");
@@ -3362,6 +3362,9 @@
   // lexical context will be different from the semantic context.
   New->setLexicalDeclContext(CurContext);
 
+  if (AS != AS_none)
+    New->setAccess(AS);
+
   if (TK == TK_Definition)
     New->startDefinition();
   
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index d9f6902..ff474fa 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -173,6 +173,7 @@
   EnumDecl *Enum = EnumDecl::Create(SemaRef.Context, Owner, 
                                     D->getLocation(), D->getIdentifier(),
                                     /*PrevDecl=*/0);
+  Enum->setAccess(D->getAccess());
   Owner->addDecl(Enum);
   Enum->startDefinition();