[cfe-commits] r81584 - in /cfe/trunk: lib/Sema/SemaInherit.cpp lib/Sema/SemaLookup.cpp test/CXX/temp/temp.res/temp.dep/p3.cpp

Douglas Gregor dgregor at apple.com
Fri Sep 11 15:57:37 PDT 2009


Author: dgregor
Date: Fri Sep 11 17:57:37 2009
New Revision: 81584

URL: http://llvm.org/viewvc/llvm-project?rev=81584&view=rev
Log:
When performing name lookup within a class template or class template
partial specialization, make sure we look into non-dependent base
classes (but not dependent base classes). Fixes PR4951.


Added:
    cfe/trunk/test/CXX/temp/temp.res/temp.dep/p3.cpp
Modified:
    cfe/trunk/lib/Sema/SemaInherit.cpp
    cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaInherit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInherit.cpp?rev=81584&r1=81583&r2=81584&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInherit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInherit.cpp Fri Sep 11 17:57:37 2009
@@ -139,9 +139,12 @@
     QualType BaseType = Context.getCanonicalType(BaseSpec->getType());
     BaseType = BaseType.getUnqualifiedType();
 
-    // If a base class of the class template depends on a template-parameter,
-    // the base class scope is not examined during unqualified name lookup.
-    // [temp.dep]p3.
+    // C++ [temp.dep]p3:
+    //   In the definition of a class template or a member of a class template,
+    //   if a base class of the class template depends on a template-parameter,
+    //   the base class scope is not examined during unqualified name lookup 
+    //   either at the point of definition of the class template or member or 
+    //   during an instantiation of the class tem- plate or member.
     if (BaseType->isDependentType())
       continue;
 

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=81584&r1=81583&r2=81584&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Sep 11 17:57:37 2009
@@ -1032,9 +1032,8 @@
       return LookupResult::CreateLookupResult(Context, I, E);
 
   // If this isn't a C++ class, we aren't allowed to look into base
-  // classes, we're done, or the lookup context is dependent, we're done.
-  if (RedeclarationOnly || !isa<CXXRecordDecl>(LookupCtx) ||
-      LookupCtx->isDependentContext())
+  // classes, we're done.
+  if (RedeclarationOnly || !isa<CXXRecordDecl>(LookupCtx))
     return LookupResult::CreateLookupResult(Context, 0);
 
   // Perform lookup into our base classes.

Added: cfe/trunk/test/CXX/temp/temp.res/temp.dep/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.res/temp.dep/p3.cpp?rev=81584&view=auto

==============================================================================
--- cfe/trunk/test/CXX/temp/temp.res/temp.dep/p3.cpp (added)
+++ cfe/trunk/test/CXX/temp/temp.res/temp.dep/p3.cpp Fri Sep 11 17:57:37 2009
@@ -0,0 +1,43 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+struct A0 {
+  struct K { };
+};
+
+template <typename T> struct B0: A0 {
+  static void f() {
+    K k;
+  }
+};
+
+namespace E1 {
+  typedef double A; 
+
+  template<class T> class B {
+    typedef int A; 
+  };
+
+  template<class T> 
+  struct X : B<T> {
+    A* blarg(double *dp) {
+      return dp;
+    }
+  };
+}
+
+namespace E2 {
+  struct A { 
+    struct B;
+    int *a;
+    int Y;
+  };
+    
+  int a;
+  template<class T> struct Y : T { 
+    struct B { /* ... */ };
+    B b; 
+    void f(int i) { a = i; } 
+    Y* p;
+  }; 
+  
+  Y<A> ya;
+}





More information about the cfe-commits mailing list