[cfe-commits] r127512 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaTemplate/nested-name-spec-template.cpp

Douglas Gregor dgregor at apple.com
Fri Mar 11 15:27:41 PST 2011


Author: dgregor
Date: Fri Mar 11 17:27:41 2011
New Revision: 127512

URL: http://llvm.org/viewvc/llvm-project?rev=127512&view=rev
Log:
Don't ask if a depenendent CXXRecordDecl has any dependent bases
unless we already know that it has a definition. Fixes
PR9449/<rdar://problem/9115785>.

Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/SemaTemplate/nested-name-spec-template.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=127512&r1=127511&r2=127512&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Mar 11 17:27:41 2011
@@ -2036,7 +2036,8 @@
                                           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(),

Modified: cfe/trunk/test/SemaTemplate/nested-name-spec-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/nested-name-spec-template.cpp?rev=127512&r1=127511&r2=127512&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/nested-name-spec-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/nested-name-spec-template.cpp Fri Mar 11 17:27:41 2011
@@ -127,3 +127,16 @@
 
   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}}
+}





More information about the cfe-commits mailing list