Hi Douglas,
Thank you for review.
I am attaching an updated patch with the following changes:

  1. The diagnostic is moved from lib/Parse to lib/SemaTemplate;
  2. Added a new test to test/SemaTemplate instead of test/Parser;
  3. In test/SemaTemplate/instantiate-exception-spec-cxx11.cpp, moved the class 
definition outside of the
      function body to avoid triggering the new diagnostic.
      I did experiment with adding an expected-error annotation there, but it 
seems that delaying the diagnostic
      from Parser to Sema triggers quite a few more error messages, e.g.,
          Line 52: use of undeclared identifier 'f'
          Line 54: no member named 'f' in 'S'
      I think adding more expected-error annotations would unnecessarily 
complicate the existing test. The
      proposed new test checks both function and class templates.

Could you review?
- Gao.

________________________________________
From: Douglas Gregor [[email protected]]
Sent: Wednesday, March 13, 2013 4:13 PM
To: Gao, Yunzhong
Cc: [email protected]
Subject: Re: [PATCH] Adding a diagnostic for member templates inside a local 
class

On Mar 13, 2013, at 12:55 PM, "Gao, Yunzhong" <[email protected]> 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





_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to