aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-10-28 02:33:00 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-10-27 21:33:00 -0500
commitd32789d814b14b23eba3fc2cea61168946475699 (patch)
treed1ce2aa75fec8198aff1d84542fe1d6534b1befc
parent2c4eb7946e44e2e990ef7cd1167c853eeebde26d (diff)
downloadgcc-d32789d814b14b23eba3fc2cea61168946475699.zip
gcc-d32789d814b14b23eba3fc2cea61168946475699.tar.gz
gcc-d32789d814b14b23eba3fc2cea61168946475699.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/pt.c36
2 files changed, 39 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b47514b..c1bb904 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
1998-10-28 Jason Merrill <jason@yorick.cygnus.com>
+ * 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 c0726b7..12ff526 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