re PR c++/28860 (Trouble with bound template template parameter in specialization)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Mon, 28 Aug 2006 22:34:55 +0000 (22:34 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Mon, 28 Aug 2006 22:34:55 +0000 (22:34 +0000)
PR c++/28860
* cp-tree.h (maybe_process_partial_specialization): Return
tree instead of void.
* parser.c (cp_parser_class_head): Use return value of
maybe_process_partial_specialization.
* pt.c (maybe_process_partial_specialization): Return error_mark_node
for broken specializations, TYPE otherwise.  Check for template
template parameters.

* g++.dg/template/ttp22.C: New test.

From-SVN: r116541

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/ttp22.C [new file with mode: 0644]

index 369a678036a98c245d099d9a5ffe25678f366efe..8b7eae9dfb92833fe5e1d158a892ecb53c8da343 100644 (file)
@@ -1,3 +1,14 @@
+2006-08-28  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/28860
+       * cp-tree.h (maybe_process_partial_specialization): Return
+       tree instead of void.
+       * parser.c (cp_parser_class_head): Use return value of
+       maybe_process_partial_specialization.
+       * pt.c (maybe_process_partial_specialization): Return error_mark_node
+       for broken specializations, TYPE otherwise.  Check for template
+       template parameters.
+
 2006-08-27  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/28058
index c50836b0be0ad4467d965d38f7f2cc9e81a4ede5..3c20afed5ec14397538b180cdc8f25a9f17ea3b1 100644 (file)
@@ -4111,7 +4111,7 @@ extern int template_class_depth                   (tree);
 extern int is_specialization_of                        (tree, tree);
 extern bool is_specialization_of_friend                (tree, tree);
 extern int comp_template_args                  (tree, tree);
-extern void maybe_process_partial_specialization (tree);
+extern tree maybe_process_partial_specialization (tree);
 extern tree most_specialized_instantiation     (tree);
 extern void print_candidates                   (tree);
 extern void instantiate_pending_templates      (int);
index a97518ac9a58d2d57702af2bab86ae0b1847a9b3..5271113485a7c2775fa4e2a45e11c543e18af360 100644 (file)
@@ -13287,7 +13287,7 @@ cp_parser_class_head (cp_parser* parser,
   if (template_id_p)
     {
       type = TREE_TYPE (id);
-      maybe_process_partial_specialization (type);
+      type = maybe_process_partial_specialization (type);
       if (nested_name_specifier)
        pushed_scope = push_scope (nested_name_specifier);
     }
index 17557c0fffaeacedabd3fc5da18ace644dc5c1ae..79d9de4e4ce79fd0134258696318901de197f5f8 100644 (file)
@@ -673,13 +673,20 @@ check_explicit_instantiation_namespace (tree spec)
 /* The TYPE is being declared.  If it is a template type, that means it
    is a partial specialization.  Do appropriate error-checking.  */
 
-void
+tree
 maybe_process_partial_specialization (tree type)
 {
   tree context;
 
   if (type == error_mark_node)
-    return;
+    return error_mark_node;
+
+  if (TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM)
+    {
+      error ("name of class shadows template template parameter %qD",
+            TYPE_NAME (type));
+      return error_mark_node;
+    }
 
   context = TYPE_CONTEXT (type);
 
@@ -764,7 +771,12 @@ maybe_process_partial_specialization (tree type)
        }
     }
   else if (processing_specialization)
-    error ("explicit specialization of non-template %qT", type);
+    {
+      error ("explicit specialization of non-template %qT", type);
+      return error_mark_node;
+    }
+
+  return type;
 }
 
 /* Returns nonzero if we can optimize the retrieval of specializations
index 767f94e3a84d7e1a061ee9f0d86a4f1b3a015ca2..6e2043195bcb4c6bd28033985b1ce584bdd53347 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-28  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/28860
+       * g++.dg/template/ttp22.C: New test.
+
 2006-08-28  Kazu Hirata  <kazu@codesourcery.com>
 
        PR middle-end/26632
diff --git a/gcc/testsuite/g++.dg/template/ttp22.C b/gcc/testsuite/g++.dg/template/ttp22.C
new file mode 100644 (file)
index 0000000..f344943
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/28860
+// { dg-do compile}
+
+template<template<int> class A>
+class A<0>;  // { dg-error "shadows template template parameter" }
+
+template<template<int> class B>
+class B<0> {};  // { dg-error "shadows template template parameter" }