On Mar 20, 2018, Jason Merrill <ja...@redhat.com> wrote:

> On Tue, Mar 20, 2018 at 4:15 PM, Alexandre Oliva <aol...@redhat.com> wrote:
>> Should we aim at rejecting the declaration of U?

> Yes.

Like this?

[PR c++/71251] check tmpl parms in template using decl

Check that template using decls have the correct number of parm lists.

Will regstrap shortly, ok to install if it passes?

for  gcc/cp/ChangeLog

        PR c++/71251
        * parser.c (cp_parser_alias_declaration): Call
        parser_check_template_parameters.

for  gcc/testsuite/ChangeLog

        PR c++/71251
        * g++.dg/cpp0x/pr71251.C: New.
---
 gcc/cp/parser.c                      |   10 ++++++++++
 gcc/testsuite/g++.dg/cpp0x/pr71251.C |   15 +++++++++++++++
 2 files changed, 25 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr71251.C

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index ce05615adfba..8fa6a37c82f0 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -18910,6 +18910,13 @@ cp_parser_alias_declaration (cp_parser* parser)
   if (id == error_mark_node)
     return error_mark_node;
 
+  if (parser->num_template_parameter_lists
+      && !cp_parser_check_template_parameters (parser,
+                                              /*num_templates=*/0,
+                                              id_location,
+                                              /*declarator=*/NULL))
+    id = error_mark_node;
+
   cp_token *attrs_token = cp_lexer_peek_token (parser->lexer);
   attributes = cp_parser_attributes_opt (parser);
   if (attributes == error_mark_node)
@@ -18980,6 +18987,9 @@ cp_parser_alias_declaration (cp_parser* parser)
                               ds_alias,
                               using_token);
 
+  if (id == error_mark_node)
+    return error_mark_node;
+
   declarator = make_id_declarator (NULL_TREE, id, sfk_none);
   declarator->id_loc = id_location;
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr71251.C 
b/gcc/testsuite/g++.dg/cpp0x/pr71251.C
new file mode 100644
index 000000000000..3df831bb581d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr71251.C
@@ -0,0 +1,15 @@
+// { dg-do compile { target c++11 } }
+
+template<int,int> template<typename>
+using U = void; // { dg-error "too many" }
+
+template<typename>
+using V = void;
+
+template<typename> struct X {
+  template<typename> template<typename>
+  using U = void; // { dg-error "too many" }
+
+  template<typename>
+  using V = void;
+};


-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer

Reply via email to