]> granicus.if.org Git - clang/commitdiff
When a nested-name-specifier refers into a current instantiation that has
authorDouglas Gregor <dgregor@apple.com>
Wed, 28 Jul 2010 14:49:07 +0000 (14:49 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 28 Jul 2010 14:49:07 +0000 (14:49 +0000)
dependent bases, construct a dependent nested-name-specifier rather
than complaining that the name could not be found within the current
instantiation itself. Fixes PR7725.

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

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

index f56573a8de26b1b2560a4858f9c2089506993351..f2048fe31c372b7e69c6c6529984eec6b357c79d 100644 (file)
@@ -416,7 +416,17 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
 
       ObjectTypeSearchedInScope = true;
     }
-  } else if (isDependent) {
+  } else if (!isDependent) {
+    // Perform unqualified name lookup in the current scope.
+    LookupName(Found, S);
+  }
+
+  // If we performed lookup into a dependent context and did not find anything,
+  // that's fine: just build a dependent nested-name-specifier.
+  if (Found.empty() && isDependent &&
+      !(LookupCtx && LookupCtx->isRecord() &&
+        (!cast<CXXRecordDecl>(LookupCtx)->hasDefinition() ||
+         !cast<CXXRecordDecl>(LookupCtx)->hasAnyDependentBases()))) {
     // Don't speculate if we're just trying to improve error recovery.
     if (ErrorRecoveryLookup)
       return 0;
@@ -429,11 +439,8 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
       return NestedNameSpecifier::Create(Context, &II);
 
     return NestedNameSpecifier::Create(Context, Prefix, &II);
-  } else {
-    // Perform unqualified name lookup in the current scope.
-    LookupName(Found, S);
-  }
-
+  } 
+  
   // FIXME: Deal with ambiguities cleanly.
 
   if (Found.empty() && !ErrorRecoveryLookup) {
index 12ab48680915bbb10aca3566410f875eab77c17d..9c72845fb6a64aabb99a45ba7d9908321d6723e0 100644 (file)
@@ -88,3 +88,14 @@ namespace PR7385 {
 
   has_xxx0<int>::type t; // expected-note{{instantiation of}}
 }
+
+namespace PR7725 {
+  template<class ignored> struct TypedefProvider;
+  template<typename T>
+  struct TemplateClass : public TypedefProvider<T>
+  {
+    void PrintSelf() {
+      TemplateClass::Test::PrintSelf();
+    }
+  };
+}