[PATCH] Adding a diagnostic for member templates inside a local class

Douglas Gregor dgregor at apple.com
Wed Mar 13 16:13:06 PDT 2013


On Mar 13, 2013, at 12:55 PM, "Gao, Yunzhong" <Yunzhong.Gao at am.sony.com> wrote:

> Hi,
> Currently, clang++ accepts the following codes without any error message.
> 
> int test(void)
> {
>  class A {
>    template<class T> class B
>    {  T t; };
>  };
> 
>  return 0;
> }
> 
> However, I believe that an error message is required according to the C++03 and C++11.
> In particular, section 14.5 clause 2 (of both specs) says "A local class shall not have member templates."
> 
> The following patch adds a diagnostic for member templates declared inside a local class.

Generally, this looks good. However, I'd like to see it diagnosed in Sema, rather than in the parser, which we do for static data members and friends in local classes.

	- Doug





More information about the cfe-commits mailing list