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

Chris Lattner clattner at apple.com
Wed Aug 26 13:22:29 PDT 2009


On Aug 26, 2009, at 11:54 AM, Douglas Gregor wrote:

> 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

This seems very similar to the canonical type problem (but much much  
simpler!).  Maybe there should be a little helper class that is only  
comparable with == if you get the primary context?  Would it be worth  
it to do that?

-Chris

>
> 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<>'}}
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list