]> granicus.if.org Git - clang/commitdiff
Set the access specifier for templates inside classes.
authorAnders Carlsson <andersca@mac.com>
Thu, 26 Mar 2009 01:24:28 +0000 (01:24 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 26 Mar 2009 01:24:28 +0000 (01:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67726 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaCXX/access.cpp

index b8b1f3a5bb58753849fae2100696050708d8a7c0..697582c82c39433b8e644ef7e12d0e4a1d7e448a 100644 (file)
@@ -503,6 +503,9 @@ Sema::ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
                                 NewClass, PrevClassTemplate);
   NewClass->setDescribedClassTemplate(NewTemplate);
 
+  // Set the access specifier.
+  SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
+  
   // Set the lexical context of these templates
   NewClass->setLexicalDeclContext(CurContext);
   NewTemplate->setLexicalDeclContext(CurContext);
index d95781c1b7641a62b92a4242dd9cb4ce77cf3f7e..cfbc9c80692b21cfdd871beaf8dcaae632f3282f 100644 (file)
@@ -2,8 +2,8 @@
 
 class C {
     struct S; // expected-note {{previously declared 'private' here}}
-    
 public:
+    
     struct S {}; // expected-error {{'S' redeclared with 'public' access}}
 };
 
@@ -12,4 +12,12 @@ struct S {
     
 private:
     class C { }; // expected-error {{'C' redeclared with 'private' access}}
-};
\ No newline at end of file
+};
+
+class T {
+protected:
+    template<typename T> struct A; // expected-note {{previously declared 'protected' here}}
+    
+private:
+    template<typename T> struct A {}; // expected-error {{'A' redeclared with 'private' access}}
+};