On Tue, Apr 10, 2018 at 9:50 AM, Jason Merrill <ja...@redhat.com> wrote:
> On Mon, Apr 9, 2018 at 6:55 PM, Paolo Carlini <paolo.carl...@oracle.com>
>> On 09/04/2018 21:39, Jason Merrill wrote:
>>> cp_parser_check_template_parameters is supposed to catch when we have
>>> the wrong number of template parameter lists, but it wasn't diagnosing
>>> this case. Fixed by checking whether the thing we're declaring used a
>>> template-id; the case of declaring a primary template, when we allow
>>> one more template parameter list, uses a plain identifier.
>> Nice, it looks like this also fixes the prehistoric c++/24314, which I still
>> had assigned.
>> When I worked a bit on it, relatively recently, in 2012, I
>> failed to properly follow-up to your feedback on the mailing list, but I
>> don't think we really nailed the problem, did we?
>> Or maybe we just tried to do too much, like doing away completely with
>> cp_parser_check_template_parameters in favor of a bit of additional checking
>> in maybe_process_partial_specialization.
> I'm sure late checking like we discussed there can also work, but this
> ended up being a simple way to make the current code work better...
But as discussed in that thread, we should still improve the comment:
Author: Jason Merrill <ja...@redhat.com>
Date: Tue Apr 10 09:42:54 2018 -0400
* parser.c (cp_parser_check_template_parameters): Improve comment.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index d4b62c75c44..849a75a1a51 100644
@@ -26452,8 +26452,8 @@ cp_parser_check_template_parameters (cp_parser* parser,
lists, that's OK. */
if (parser->num_template_parameter_lists == num_templates)
- /* If there are more, but only one more, then we are referring to a
- member template. That's OK too. */
+ /* If there are more, but only one more, and the name ends in an identifier,
+ then we are declaring a primary template. That's OK too. */
&& parser->num_template_parameter_lists == num_templates + 1)