C++/24314 (was: Re: [C++ Patch] PR 18747)

2012-09-07 Thread Paolo Carlini
On 09/07/2012 09:44 PM, Jason Merrill wrote: On 09/06/2012 06:29 PM, Paolo Carlini wrote: Ok, I did that in the below, also passes testing. This patch is OK. Great, applied. In the meanwhile I looked a bit more into C++/24314 itself, and figured out something, I'm attaching a draft-draft pa

Re: [C++ Patch] PR 18747

2012-09-07 Thread Jason Merrill
On 09/06/2012 06:29 PM, Paolo Carlini wrote: Ok, I did that in the below, also passes testing. This patch is OK. Jason

Re: [C++ Patch] PR 18747

2012-09-06 Thread Paolo Carlini
Hi, On 09/06/2012 07:47 PM, Jason Merrill wrote: On 09/06/2012 12:18 PM, Paolo Carlini wrote: On 09/06/2012 02:03 AM, Jason Merrill wrote: but note that for: template struct A { int select() { return 0; } }; we have parser->num_template_parameter_lists == 1 and num_templates == 0. Thus

Re: [C++ Patch] PR 18747

2012-09-06 Thread Jason Merrill
On 09/06/2012 12:18 PM, Paolo Carlini wrote: On 09/06/2012 02:03 AM, Jason Merrill wrote: but note that for: template struct A { int select() { return 0; } }; we have parser->num_template_parameter_lists == 1 and num_templates == 0. Thus it seems that the case 'num_templates + 1' isn't (j

Re: [C++ Patch] PR 18747

2012-09-06 Thread Paolo Carlini
Hi, On 09/06/2012 02:03 AM, Jason Merrill wrote: but note that for: template struct A { int select() { return 0; } }; we have parser->num_template_parameter_lists == 1 and num_templates == 0. Thus it seems that the case 'num_templates + 1' isn't (just) about member templates... That's o

Re: [C++ Patch] PR 18747

2012-09-05 Thread Jason Merrill
On 09/05/2012 02:17 PM, Paolo Carlini wrote: In fact, something seems weird earlier, in cp_parser_check_template_parameters. It has: /* If there are the same number of template classes and parameter lists, that's OK. */ if (parser->num_template_parameter_lists == num_templates)

Re: [C++ Patch] PR 18747

2012-09-05 Thread Paolo Carlini
On 09/05/2012 06:52 PM, Paolo Carlini wrote: On 09/05/2012 06:41 PM, Paolo Carlini wrote: Thanks for looking into this. Now I wonder if we made progress on a couple of long standing PRs where we weren't strict enough by one with the number of 'template <>'. Let me check... Nope, apparently c++/

Re: [C++ Patch] PR 18747

2012-09-05 Thread Paolo Carlini
On 09/05/2012 06:41 PM, Paolo Carlini wrote: Thanks for looking into this. Now I wonder if we made progress on a couple of long standing PRs where we weren't strict enough by one with the number of 'template <>'. Let me check... Nope, apparently c++/24314 is still there. But maybe it's easier to

Re: [C++ Patch] PR 18747

2012-09-05 Thread Paolo Carlini
Hi, On 08/31/2012 11:32 PM, Jason Merrill wrote: Since you're traveling, I poked at this myself some more. The issue here is that there are too many template headers for the declaration, so we want to figure out what the right number is and give an appropriate message. Tested x86_64-pc-linu

Re: [C++ Patch] PR 18747

2012-08-31 Thread Jason Merrill
Since you're traveling, I poked at this myself some more. The issue here is that there are too many template headers for the declaration, so we want to figure out what the right number is and give an appropriate message. Tested x86_64-pc-linux-gnu, applying to trunk. commit 7c8fead9f721b04227

Re: [C++ Patch] PR 18747

2012-08-23 Thread Paolo Carlini
Hi again, On 08/23/2012 05:53 PM, Paolo Carlini wrote: On 08/23/2012 05:24 PM, Jason Merrill wrote: On 08/23/2012 10:04 AM, Paolo Carlini wrote: +if (decl +&& TREE_CODE (decl) == VAR_DECL +&& ! TYPE_P (CP_DECL_CONTEXT (decl))) + { +error_at (decl_spec_token_start->location

Re: [C++ Patch] PR 18747

2012-08-23 Thread Paolo Carlini
On 08/23/2012 05:24 PM, Jason Merrill wrote: On 08/23/2012 10:04 AM, Paolo Carlini wrote: +if (decl +&& TREE_CODE (decl) == VAR_DECL +&& ! TYPE_P (CP_DECL_CONTEXT (decl))) + { +error_at (decl_spec_token_start->location, + "%qT is not a template type", TREE_TYPE (dec

Re: [C++ Patch] PR 18747

2012-08-23 Thread Jason Merrill
On 08/23/2012 10:04 AM, Paolo Carlini wrote: +if (decl + && TREE_CODE (decl) == VAR_DECL + && ! TYPE_P (CP_DECL_CONTEXT (decl))) + { + error_at (decl_spec_token_start->location, + "%qT is not a template type", TREE_TYPE (decl)); + decl = error_mark

[C++ Patch] PR 18747

2012-08-23 Thread Paolo Carlini
Hi, here we want to reject meaningless things like: template<> int i; // { dg-error "template" } struct A { }; template<> A j; // { dg-error "template" } It seems to me that a good place to do that is toward the end of cp_parser_single_declaration, where we have only to be careful with