[cfe-commits] [PATCH]Fix a false warning against explicit template specialization for nested types

Douglas Gregor dgregor at apple.com
Wed Jun 1 15:42:47 PDT 2011


On Jun 1, 2011, at 5:15 AM, Michael Han wrote:

> Hi there, I find a clang warning is suspicious.
>  
> Consider this code:          
>  
> template <typename T1> struct A {
>     template <typename T2> struct B {
>         template <typename T3> struct C {
>             static void foo();
>         };
>     };
> };
>  
> template <> struct A<int> {
>     template <typename T2> struct B {
>         template <typename T3> struct C {
>             static void foo();
>         };
>     };
> };
>  
> template <> template <typename T3> struct A<int>::B<int>::C {
>     static void foo();
> };
>  
> Clang would emit a warning like “extraneous template parameter list in template specialization” at
> template <> template <typename T3> struct A<int>::B<int>::C. I think the code should not trigger a warning here since the first template <> is applied to the explicit specialization of the nested class template B, not to A as indicated by the “note” of clang diagnostic (since A has already had a declaration of an explicit specialization so the template <> for A could be omitted)
>  
> After looking at the code, it looks like the problem is in SemaTemplate.cpp when iterating the nested types, the loop is terminated before it should be so the template header is never consumed. The attached patch fixes this, with a test added.
>  
> Please review, thanks!

This looks great, thanks! I've committed it as r132431.

	- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110601/633ca679/attachment.html>


More information about the cfe-commits mailing list