[cfe-commits] r80126 - in /cfe/trunk: lib/Sema/IdentifierResolver.cpp test/SemaTemplate/class-template-spec.cpp

Douglas Gregor dgregor at apple.com
Wed Aug 26 11:54:58 PDT 2009


Author: dgregor
Date: Wed Aug 26 13:54:58 2009
New Revision: 80126

URL: http://llvm.org/viewvc/llvm-project?rev=80126&view=rev
Log:
Make sure to compare primary declaration contexts when determining whether a declaration is in scope

Modified:
    cfe/trunk/lib/Sema/IdentifierResolver.cpp
    cfe/trunk/test/SemaTemplate/class-template-spec.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Wed Aug 26 13:54:58 2009
@@ -134,7 +134,8 @@
     return false;
   }
 
-  return D->getDeclContext()->getLookupContext() == Ctx->getPrimaryContext();
+  return D->getDeclContext()->getLookupContext()->getPrimaryContext() == 
+    Ctx->getPrimaryContext();
 }
 
 /// AddDecl - Link the decl to its shadowed decl chain.

Modified: cfe/trunk/test/SemaTemplate/class-template-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/class-template-spec.cpp?rev=80126&r1=80125&r2=80126&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/class-template-spec.cpp (original)
+++ cfe/trunk/test/SemaTemplate/class-template-spec.cpp Wed Aug 26 13:54:58 2009
@@ -49,6 +49,25 @@
 
 A<char>::A() { }
 
+// Make sure we can see specializations defined before the primary template.
+namespace N{ 
+  template<typename T> struct A0;
+}
+
+namespace N {
+  template<>
+  struct A0<void> {
+    typedef void* pointer;
+  };
+}
+
+namespace N {
+  template<typename T>
+  struct A0 {
+    void foo(A0<void>::pointer p = 0);
+  };
+}
+
 // Diagnose specialization errors
 struct A<double> { }; // expected-error{{template specialization requires 'template<>'}}
 





More information about the cfe-commits mailing list