]> granicus.if.org Git - clang/commitdiff
When performing template name lookup for a dependent member access
authorDouglas Gregor <dgregor@apple.com>
Fri, 16 Jul 2010 16:54:17 +0000 (16:54 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 16 Jul 2010 16:54:17 +0000 (16:54 +0000)
expression such as the "foo" in "this->blah.foo<1, 2>", and we can't
look into the type of "this->blah" (e.g., because it is dependent),
look into the local scope of a template of the same name. Fixes
<rdar://problem/8198511>.

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

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/member-template-access-expr.cpp

index f121954eed6eddcd52ab3143e8520117a640507d..c654e008b502b7797746589a7d8105e426923f54 100644 (file)
@@ -238,13 +238,10 @@ void Sema::LookupTemplateName(LookupResult &Found,
       //   expression. If the identifier is not found, it is then looked up in
       //   the context of the entire postfix-expression and shall name a class
       //   or function template.
-      //
-      // FIXME: When we're instantiating a template, do we actually have to
-      // look in the scope of the template? Seems fishy...
       if (S) LookupName(Found, S);
       ObjectTypeSearchedInScope = true;
     }
-  } else if (isDependent) {
+  } else if (isDependent && (!S || ObjectType.isNull())) {
     // We cannot look into a dependent object type or nested nme
     // specifier.
     MemberOfUnknownSpecialization = true;
@@ -282,8 +279,11 @@ void Sema::LookupTemplateName(LookupResult &Found,
   }
 
   FilterAcceptableTemplateNames(Context, Found);
-  if (Found.empty())
+  if (Found.empty()) {
+    if (isDependent)
+      MemberOfUnknownSpecialization = true;
     return;
+  }
 
   if (S && !ObjectType.isNull() && !ObjectTypeSearchedInScope) {
     // C++ [basic.lookup.classref]p1:
index ea17cdbb586477369353478b88988432c993db48..dbd27c456c5105be1fa121a5cfb821109d4eab1d 100644 (file)
@@ -123,3 +123,22 @@ namespace PR6021 {
     };
   };
 }
+
+namespace rdar8198511 {
+  template<int, typename U>
+  struct Base { 
+    void f();
+  };
+
+  template<typename T>
+  struct X0 : Base<1, T> { };
+
+  template<typename T>
+  struct X1 {
+    X0<int> x0;
+
+    void f() {
+      this->x0.Base<1, int>::f();
+    }
+  };
+}