From: Douglas Gregor Date: Fri, 11 Mar 2011 23:27:41 +0000 (+0000) Subject: Don't ask if a depenendent CXXRecordDecl has any dependent bases X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d078bd2e02bd4e6661fe06645d98280a2a5a3e8c;p=clang Don't ask if a depenendent CXXRecordDecl has any dependent bases unless we already know that it has a definition. Fixes PR9449/. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127512 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 23329a3ab6..ec1cf6c556 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -2036,7 +2036,8 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S, MemberOfUnknownSpecialization); if (TNK == TNK_Non_template && LookupCtx->isDependentContext() && isa(LookupCtx) && - cast(LookupCtx)->hasAnyDependentBases()) { + (!cast(LookupCtx)->hasDefinition() || + cast(LookupCtx)->hasAnyDependentBases())) { // This is a dependent template. Handle it below. } else if (TNK == TNK_Non_template) { Diag(Name.getSourceRange().getBegin(), diff --git a/test/SemaTemplate/nested-name-spec-template.cpp b/test/SemaTemplate/nested-name-spec-template.cpp index 7730ee395f..635687d4f6 100644 --- a/test/SemaTemplate/nested-name-spec-template.cpp +++ b/test/SemaTemplate/nested-name-spec-template.cpp @@ -127,3 +127,16 @@ namespace PR9226 { Y yxi; // expected-note{{in instantiation of template class 'PR9226::Y' requested here}} } + +namespace PR9449 { + template + struct s; // expected-note{{template is declared here}} + + template + void f() { + int s::template n::* f; // expected-error{{implicit instantiation of undefined template 'PR9449::s'}} \ + // expected-error{{following the 'template' keyword}} + } + + template void f(); // expected-note{{in instantiation of}} +}