re PR c++/28363 (Default template parameter causes compiler segfault)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Fri, 21 Jul 2006 09:41:16 +0000 (09:41 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Fri, 21 Jul 2006 09:41:16 +0000 (09:41 +0000)
PR c++/28363
* semantics.c (check_template_template_default_arg): Simplify
error handling.

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

From-SVN: r115640

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/defarg10.C [new file with mode: 0644]

index 309a060c3a2d0522c7cfaaa291805513297dc4ba..722334c17777c8dab284fc214d1cb9a5af5ae2a6 100644 (file)
@@ -1,3 +1,9 @@
+2006-07-21  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/28363
+       * semantics.c (check_template_template_default_arg): Simplify
+       error handling.
+
 2006-07-20  Jason Merrill  <jason@redhat.com>
 
        PR c++/28407
index 4577bd386f9a0fc9661bdfe5ae63916769d58db5..c739d613241c06549f91ebe6744c873ed7317cbb 100644 (file)
@@ -2143,19 +2143,8 @@ check_template_template_default_arg (tree argument)
       && TREE_CODE (argument) != UNBOUND_CLASS_TEMPLATE)
     {
       if (TREE_CODE (argument) == TYPE_DECL)
-       {
-         tree t = TREE_TYPE (argument);
-
-         /* Try to emit a slightly smarter error message if we detect
-            that the user is using a template instantiation.  */
-         if (CLASSTYPE_TEMPLATE_INFO (t)
-             && CLASSTYPE_TEMPLATE_INSTANTIATION (t))
-           error ("invalid use of type %qT as a default value for a "
-                  "template template-parameter", t);
-         else
-           error ("invalid use of %qD as a default value for a template "
-                  "template-parameter", argument);
-       }
+       error ("invalid use of type %qT as a default value for a template "
+              "template-parameter", TREE_TYPE (argument));
       else
        error ("invalid default argument for a template template parameter");
       return error_mark_node;
index 414d3143d99759b7a5da48eaf402ed688f1378e7..d56ce67b23346605949a150011b2ad3179498360 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-21  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/28363
+       * g++.dg/template/defarg10.C: New test.
+
 2006-07-20  Paul Brook  <paul@codesourcery.com>
 
        PR 27363
diff --git a/gcc/testsuite/g++.dg/template/defarg10.C b/gcc/testsuite/g++.dg/template/defarg10.C
new file mode 100644 (file)
index 0000000..281b108
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/28363
+// { dg-do compile }
+
+template<typename T, template<int> class = T>  // { dg-error "invalid use of type" }
+struct A;
+
+typedef int I;
+template<template<int> class = I>  // { dg-error "invalid use of type" }
+struct B;
+
+struct S;
+template<template<int> class = S>  // { dg-error "invalid use of type" }
+struct C;