Partial and full specializations of a class template may have a
different tag kind ("struct" vs. "class") than the primary template,
which has an affect on access control.

Should fix the last remaining Boost.Accumulors failure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103144 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 6b87463..23b3601 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -504,7 +504,6 @@
   SetClassDeclAttributesFromBase(Class, CXXBaseDecl, Virtual);
   
   // Create the base specifier.
-  // FIXME: Allocate via ASTContext?
   return new (Context) CXXBaseSpecifier(SpecifierRange, Virtual,
                               Class->getTagKind() == RecordDecl::TK_class,
                               Access, BaseType);
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 050bbbd..4689a53 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -1506,10 +1506,11 @@
       // specialization. Create the canonical declaration and add it to
       // the set of specializations.
       Decl = ClassTemplateSpecializationDecl::Create(Context,
-                                    ClassTemplate->getDeclContext(),
-                                    ClassTemplate->getLocation(),
-                                    ClassTemplate,
-                                    Converted, 0);
+                            ClassTemplate->getTemplatedDecl()->getTagKind(),
+                                                ClassTemplate->getDeclContext(),
+                                                ClassTemplate->getLocation(),
+                                                ClassTemplate,
+                                                Converted, 0);
       ClassTemplate->getSpecializations().InsertNode(Decl, InsertPos);
       Decl->setLexicalDeclContext(CurContext);
     }
@@ -3798,7 +3799,7 @@
     unsigned SequenceNumber = PrevPartial? PrevPartial->getSequenceNumber()
                             : ClassTemplate->getPartialSpecializations().size();
     ClassTemplatePartialSpecializationDecl *Partial
-      = ClassTemplatePartialSpecializationDecl::Create(Context,
+      = ClassTemplatePartialSpecializationDecl::Create(Context, Kind,
                                              ClassTemplate->getDeclContext(),
                                                        TemplateNameLoc,
                                                        TemplateParams,
@@ -3859,7 +3860,7 @@
     // Create a new class template specialization declaration node for
     // this explicit specialization or friend declaration.
     Specialization
-      = ClassTemplateSpecializationDecl::Create(Context,
+      = ClassTemplateSpecializationDecl::Create(Context, Kind,
                                              ClassTemplate->getDeclContext(),
                                                 TemplateNameLoc,
                                                 ClassTemplate,
@@ -4705,7 +4706,7 @@
     // Create a new class template specialization declaration node for
     // this explicit specialization.
     Specialization
-      = ClassTemplateSpecializationDecl::Create(Context,
+      = ClassTemplateSpecializationDecl::Create(Context, Kind,
                                              ClassTemplate->getDeclContext(),
                                                 TemplateNameLoc,
                                                 ClassTemplate,
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 14bd243..c7489ad 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1169,6 +1169,8 @@
 
   // Start the definition of this instantiation.
   Instantiation->startDefinition();
+  
+  Instantiation->setTagKind(Pattern->getTagKind());
 
   // Do substitution on the base class specifiers.
   if (SubstBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index da84806..44bce79 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1761,7 +1761,9 @@
   
   // Create the class template partial specialization declaration.
   ClassTemplatePartialSpecializationDecl *InstPartialSpec
-    = ClassTemplatePartialSpecializationDecl::Create(SemaRef.Context, Owner, 
+    = ClassTemplatePartialSpecializationDecl::Create(SemaRef.Context, 
+                                                     PartialSpec->getTagKind(),
+                                                     Owner, 
                                                      PartialSpec->getLocation(), 
                                                      InstParams,
                                                      ClassTemplate,