]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/28860 (Trouble with bound template template parameter in specialization)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Mon, 28 Aug 2006 23:12:32 +0000 (23:12 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Mon, 28 Aug 2006 23:12:32 +0000 (23:12 +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: r116544

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 2079a2856886847361ad9a2675b04f2e22d47e0c..c0363ef140ce34fbf6c11be5e3598e76d8a01705 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-25  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/28853
index 47db45f797e5fc9a6f91ed7c41e98bac22a0d40f..41a93910dcc65eaab80c8e420e3c91e3ca50ceeb 100644 (file)
@@ -4041,7 +4041,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 13cf044cf0c8ab9f50ec168fb73258eea497cf55..5d04a2fedadd3b52c869a16509042012a4974841 100644 (file)
@@ -13008,7 +13008,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 9f22cc367d8a9404d74ebca3393bf003c3eb31e0..9ae563f50be8002577744c1108096240e2f2ecdc 100644 (file)
@@ -676,13 +676,20 @@ check_specialization_namespace (tree tmpl)
 /* 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);
 
@@ -767,7 +774,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 59b575f42789769785b93a5395d3ae3464282dde..f653f619a47a2952a097344ac5845fd05bb1a386 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-25  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/28853
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" }