From: Anders Carlsson Date: Thu, 26 Mar 2009 01:24:28 +0000 (+0000) Subject: Set the access specifier for templates inside classes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4cbe82c7c82ca0106f60296a60951d41f7d2ec7d;p=clang Set the access specifier for templates inside classes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67726 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index b8b1f3a5bb..697582c82c 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -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); diff --git a/test/SemaCXX/access.cpp b/test/SemaCXX/access.cpp index d95781c1b7..cfbc9c8069 100644 --- a/test/SemaCXX/access.cpp +++ b/test/SemaCXX/access.cpp @@ -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 struct A; // expected-note {{previously declared 'protected' here}} + +private: + template struct A {}; // expected-error {{'A' redeclared with 'private' access}} +};