From 137108da15574b56300e0da84c9e5a190e65fd3b Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Thu, 26 Mar 2009 01:24:28 +0000 Subject: [PATCH] Set the access specifier for templates inside classes. llvm-svn: 67726 --- clang/lib/Sema/SemaTemplate.cpp | 3 +++ clang/test/SemaCXX/access.cpp | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index b8b1f3a5bb58..697582c82c39 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/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/clang/test/SemaCXX/access.cpp b/clang/test/SemaCXX/access.cpp index d95781c1b764..cfbc9c80692b 100644 --- a/clang/test/SemaCXX/access.cpp +++ b/clang/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}} +};