]> granicus.if.org Git - clang/commitdiff
Don't ask if a depenendent CXXRecordDecl has any dependent bases
authorDouglas Gregor <dgregor@apple.com>
Fri, 11 Mar 2011 23:27:41 +0000 (23:27 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 11 Mar 2011 23:27:41 +0000 (23:27 +0000)
unless we already know that it has a definition. Fixes
PR9449/<rdar://problem/9115785>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127512 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/nested-name-spec-template.cpp

index 23329a3ab6c04b1dc9fe692135c49e78eb75e571..ec1cf6c556e94f0314bc03db261c2374b5ed3587 100644 (file)
@@ -2036,7 +2036,8 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S,
                                           MemberOfUnknownSpecialization);
     if (TNK == TNK_Non_template && LookupCtx->isDependentContext() &&
         isa<CXXRecordDecl>(LookupCtx) &&
-        cast<CXXRecordDecl>(LookupCtx)->hasAnyDependentBases()) {
+        (!cast<CXXRecordDecl>(LookupCtx)->hasDefinition() ||
+         cast<CXXRecordDecl>(LookupCtx)->hasAnyDependentBases())) {
       // This is a dependent template. Handle it below.
     } else if (TNK == TNK_Non_template) {
       Diag(Name.getSourceRange().getBegin(),
index 7730ee395f4b8ea21691e7e601999ce1076eb884..635687d4f6b71b53813d0a8685e8bbbce03118d2 100644 (file)
@@ -127,3 +127,16 @@ namespace PR9226 {
 
   Y<X, int> yxi; // expected-note{{in instantiation of template class 'PR9226::Y<PR9226::X, int>' requested here}}
 }
+
+namespace PR9449 {
+  template <typename T>
+  struct s; // expected-note{{template is declared here}}
+
+  template <typename T>
+  void f() {
+    int s<T>::template n<T>::* f; // expected-error{{implicit instantiation of undefined template 'PR9449::s<int>'}} \
+    // expected-error{{following the 'template' keyword}}
+  }
+
+  template void f<int>(); // expected-note{{in instantiation of}}
+}