Perform access control when template lookup finds a class template.

This is *really* hacky.

llvm-svn: 110997
This commit is contained in:
John McCall 2010-08-13 02:23:42 +00:00
parent a2622dd266
commit dcc7140f86
3 changed files with 21 additions and 5 deletions

View File

@ -454,7 +454,7 @@ public:
/// Determines whether this lookup is suppressing diagnostics.
bool isSuppressingDiagnostics() const {
return Diagnose;
return !Diagnose;
}
/// Sets a 'context' source range.

View File

@ -130,11 +130,12 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
LookupResult R(*this, TName, Name.getSourceRange().getBegin(),
LookupOrdinaryName);
R.suppressDiagnostics();
LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
MemberOfUnknownSpecialization);
if (R.empty() || R.isAmbiguous())
if (R.empty() || R.isAmbiguous()) {
R.suppressDiagnostics();
return TNK_Non_template;
}
TemplateName Template;
TemplateNameKind TemplateKind;
@ -145,6 +146,9 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
// template name in other ways.
Template = Context.getOverloadedTemplateName(R.begin(), R.end());
TemplateKind = TNK_Function_template;
// We'll do this lookup again later.
R.suppressDiagnostics();
} else {
TemplateDecl *TD = cast<TemplateDecl>((*R.begin())->getUnderlyingDecl());
@ -157,9 +161,12 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
Template = TemplateName(TD);
}
if (isa<FunctionTemplateDecl>(TD))
if (isa<FunctionTemplateDecl>(TD)) {
TemplateKind = TNK_Function_template;
else {
// We'll do this lookup again later.
R.suppressDiagnostics();
} else {
assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD));
TemplateKind = TNK_Type_template;
}

View File

@ -427,3 +427,12 @@ namespace test16 {
void b() { throw A(); } // expected-error{{temporary of type 'test16::A' has private destructor}} \
// expected-error{{exception object of type 'test16::A' has private destructor}}
}
// rdar://problem/8146294
namespace test17 {
class A {
template <typename T> class Inner { }; // expected-note {{declared private here}}
};
A::Inner<int> s; // expected-error {{'Inner' is a private member of 'test17::A'}}
}