[cfe-commits] r108531 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaTemplate/member-template-access-expr.cpp

Douglas Gregor dgregor at apple.com
Fri Jul 16 09:54:18 PDT 2010


Author: dgregor
Date: Fri Jul 16 11:54:17 2010
New Revision: 108531

URL: http://llvm.org/viewvc/llvm-project?rev=108531&view=rev
Log:
When performing template name lookup for a dependent member access
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>.


Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=108531&r1=108530&r2=108531&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Jul 16 11:54:17 2010
@@ -238,13 +238,10 @@
       //   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 @@
   }
 
   FilterAcceptableTemplateNames(Context, Found);
-  if (Found.empty())
+  if (Found.empty()) {
+    if (isDependent)
+      MemberOfUnknownSpecialization = true;
     return;
+  }
 
   if (S && !ObjectType.isNull() && !ObjectTypeSearchedInScope) {
     // C++ [basic.lookup.classref]p1:

Modified: cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp?rev=108531&r1=108530&r2=108531&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp (original)
+++ cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp Fri Jul 16 11:54:17 2010
@@ -123,3 +123,22 @@
     };
   };
 }
+
+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();
+    }
+  };
+}





More information about the cfe-commits mailing list