From: Jason Merrill Date: Wed, 28 Oct 1998 02:33:00 +0000 (+0000) Subject: pt.c (push_template_decl_real): Complain about default template args for enclosing... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d32789d814b14b23eba3fc2cea61168946475699;p=gcc.git pt.c (push_template_decl_real): Complain about default template args for enclosing classes. * pt.c (push_template_decl_real): Complain about default template args for enclosing classes. From-SVN: r23389 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b47514b0563..c1bb9044fcd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 1998-10-28 Jason Merrill + * pt.c (push_template_decl_real): Complain about default template + args for enclosing classes. + * call.c (add_function_candidate): Treat conversion functions as coming from the argument's class. * cp-tree.h (DECL_CONV_FN_P): New fn. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c0726b74e9a..12ff5260076 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2102,6 +2102,42 @@ push_template_decl_real (decl, is_friend) && CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (decl))) return process_partial_specialization (decl); + /* [temp.param] A default template-argument shall not be specified in a + function template declaration or a function template definition, nor + in the template-parameter-list of the definition of a member of a + class template. */ + { + tree parms; + int issued_default_arg_message = 0; + + parms = current_template_parms; + if (primary) + parms = TREE_CHAIN (parms); + for (; parms; parms = TREE_CHAIN (parms)) + { + tree inner_parms = TREE_VALUE (parms); + int i, ntparms; + + if (TREE_TYPE (inner_parms)) + continue; + + ntparms = TREE_VEC_LENGTH (inner_parms); + for (i = 0; i < ntparms; ++i) + { + if (TREE_PURPOSE (TREE_VEC_ELT (inner_parms, i))) + { + if (!issued_default_arg_message) + { + cp_error ("default argument for template parameter of class enclosing `%D'", + decl); + issued_default_arg_message = 1; + } + TREE_PURPOSE (TREE_VEC_ELT (inner_parms, i)) = NULL_TREE; + } + } + } + } + args = current_template_args (); if (!ctx