diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-07-19 19:28:19 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-07-19 19:28:19 +0000 |
commit | 66191c20ee094395d51eaa90465bfb4b4d23eb8c (patch) | |
tree | 88898b06eab2a6f31b58220dd98bd72252f8ba0c /gcc/cp | |
parent | 5163d20e294343d90b0e8ad7dd6411c9c40ab73f (diff) | |
download | gcc-66191c20ee094395d51eaa90465bfb4b4d23eb8c.zip gcc-66191c20ee094395d51eaa90465bfb4b4d23eb8c.tar.gz gcc-66191c20ee094395d51eaa90465bfb4b4d23eb8c.tar.bz2 |
pt.c (check_default_tmpl_args): Move test for missing default arguments here, from ...
* pt.c (check_default_tmpl_args): Move test for missing default
arguments here, from ...
(end_template_parm_list): Here.
From-SVN: r28180
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 61 |
2 files changed, 42 insertions, 25 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b7f0458..f7cce48 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +1999-07-19 Mark Mitchell <mark@codesourcery.com> + + * pt.c (check_default_tmpl_args): Move test for missing default + arguments here, from ... + (end_template_parm_list): Here. + 1999-07-18 Mark Mitchell <mark@codesourcery.com> * decl.c (lookup_nested_type): Remove. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 6106852..bb48cc8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1857,7 +1857,6 @@ end_template_parm_list (parms) int nparms; tree parm; tree saved_parmlist = make_tree_vec (list_length (parms)); - int seen_def_arg_p = 0; current_template_parms = tree_cons (build_int_2 (0, processing_template_decl), @@ -1866,25 +1865,7 @@ end_template_parm_list (parms) for (parm = parms, nparms = 0; parm; parm = TREE_CHAIN (parm), nparms++) - { - /* [temp.param] - - If a template-parameter has a default template-argument, all - subsequent template-parameters shall have a default - template-argument supplied. */ - if (TREE_PURPOSE (parm)) - seen_def_arg_p = 1; - else if (seen_def_arg_p) - { - /* Issue the error message. */ - cp_error ("no default argument for `%D'", TREE_VALUE (parm)); - /* For better subsequent error-recovery, we indicate that - there should have been a default argument. */ - TREE_PURPOSE (parm) = error_mark_node; - } - - TREE_VEC_ELT (saved_parmlist, nparms) = parm; - } + TREE_VEC_ELT (saved_parmlist, nparms) = parm; --processing_template_parmlist; @@ -2227,7 +2208,8 @@ check_default_tmpl_args (decl, parms, is_primary, is_partial) int is_partial; { const char *msg; - int last_level_to_check; + int last_level_to_check; + tree parm_level; /* [temp.param] @@ -2251,6 +2233,33 @@ check_default_tmpl_args (decl, parms, is_primary, is_partial) that the class is complete. */ return; + /* [temp.param] + + If a template-parameter has a default template-argument, all + subsequent template-parameters shall have a default + template-argument supplied. */ + for (parm_level = parms; parm_level; parm_level = TREE_CHAIN (parm_level)) + { + tree inner_parms = TREE_VALUE (parm_level); + int ntparms = TREE_VEC_LENGTH (inner_parms); + int seen_def_arg_p = 0; + int i; + + for (i = 0; i < ntparms; ++i) + { + tree parm = TREE_VEC_ELT (inner_parms, i); + if (TREE_PURPOSE (parm)) + seen_def_arg_p = 1; + else if (seen_def_arg_p) + { + cp_error ("no default argument for `%D'", TREE_VALUE (parm)); + /* For better subsequent error-recovery, we indicate that + there should have been a default argument. */ + TREE_PURPOSE (parm) = error_mark_node; + } + } + } + if (TREE_CODE (decl) != TYPE_DECL || is_partial || !is_primary) /* For an ordinary class template, default template arguments are allowed at the innermost level, e.g.: @@ -2293,11 +2302,13 @@ check_default_tmpl_args (decl, parms, is_primary, is_partial) /* Check everything. */ last_level_to_check = 0; - for (; parms && TMPL_PARMS_DEPTH (parms) >= last_level_to_check; - parms = TREE_CHAIN (parms)) + for (parm_level = parms; + parm_level && TMPL_PARMS_DEPTH (parm_level) >= last_level_to_check; + parm_level = TREE_CHAIN (parm_level)) { - tree inner_parms = TREE_VALUE (parms); - int i, ntparms; + tree inner_parms = TREE_VALUE (parm_level); + int i; + int ntparms; ntparms = TREE_VEC_LENGTH (inner_parms); for (i = 0; i < ntparms; ++i) |