From e488a090e6e7b25ca423628dc5a64bd88d793de3 Mon Sep 17 00:00:00 2001 From: Volker Reichelt Date: Fri, 21 Jul 2006 09:41:16 +0000 Subject: [PATCH] re PR c++/28363 (Default template parameter causes compiler segfault) 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 | 6 ++++++ gcc/cp/semantics.c | 15 ++------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/defarg10.C | 13 +++++++++++++ 4 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/defarg10.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 309a060c3a2..722334c1777 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-07-21 Volker Reichelt + + PR c++/28363 + * semantics.c (check_template_template_default_arg): Simplify + error handling. + 2006-07-20 Jason Merrill PR c++/28407 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 4577bd386f9..c739d613241 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 414d3143d99..d56ce67b233 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-07-21 Volker Reichelt + + PR c++/28363 + * g++.dg/template/defarg10.C: New test. + 2006-07-20 Paul Brook PR 27363 diff --git a/gcc/testsuite/g++.dg/template/defarg10.C b/gcc/testsuite/g++.dg/template/defarg10.C new file mode 100644 index 00000000000..281b1086845 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/defarg10.C @@ -0,0 +1,13 @@ +// PR c++/28363 +// { dg-do compile } + +template class = T> // { dg-error "invalid use of type" } +struct A; + +typedef int I; +template class = I> // { dg-error "invalid use of type" } +struct B; + +struct S; +template class = S> // { dg-error "invalid use of type" } +struct C;