diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e63dd396909..923158ab373 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2000-12-07 Nathan Sidwell + + * cp-tree.h (sufficient_parms_p): Declare new function. + * call.c (sufficient_parms_p): New function, broken out of ... + (add_function_candidate): ... here. Use it. + (add_conv_candidate): Use it. + * decl.c (grok_ctor_properties): Use it. + 2000-12-07 Jakub Jelinek * optimize.c (copy_body_r): Set STMT_IS_FULL_EXPR_P on EXPR_STMT. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index fd5f9046382..cbe345a3f05 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -589,6 +589,21 @@ null_ptr_cst_p (t) return 0; } + +/* Returns non-zero if PARMLIST consists of only default parms and/or + ellipsis. */ + +int +sufficient_parms_p (parmlist) + tree parmlist; +{ + for (; parmlist && parmlist != void_list_node; + parmlist = TREE_CHAIN (parmlist)) + if (!TREE_PURPOSE (parmlist)) + return 0; + return 1; +} + static tree build_conv (code, type, from) enum tree_code code; @@ -1324,13 +1339,8 @@ add_function_candidate (candidates, fn, ctype, arglist, flags) viable = 0; /* Make sure there are default args for the rest of the parms. */ - else for (; parmnode && parmnode != void_list_node; - parmnode = TREE_CHAIN (parmnode)) - if (! TREE_PURPOSE (parmnode)) - { - viable = 0; - break; - } + else if (!sufficient_parms_p (parmnode)) + viable = 0; if (! viable) goto out; @@ -1471,13 +1481,8 @@ add_conv_candidate (candidates, fn, obj, arglist) if (i < len) viable = 0; - for (; parmnode && parmnode != void_list_node; - parmnode = TREE_CHAIN (parmnode)) - if (! TREE_PURPOSE (parmnode)) - { - viable = 0; - break; - } + if (!sufficient_parms_p (parmnode)) + viable = 0; return add_candidate (candidates, totype, convs, viable); } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 5b7eca90ac0..9fcbcc2cff5 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3736,6 +3736,7 @@ extern tree build_addr_func PARAMS ((tree)); extern tree build_call PARAMS ((tree, tree)); extern tree build_method_call PARAMS ((tree, tree, tree, tree, int)); extern int null_ptr_cst_p PARAMS ((tree)); +extern int sufficient_parms_p PARAMS ((tree)); extern tree type_decays_to PARAMS ((tree)); extern tree build_user_type_conversion PARAMS ((tree, tree, int)); extern tree build_new_function_call PARAMS ((tree, tree)); @@ -4269,7 +4270,7 @@ extern tree lookup_conversions PARAMS ((tree)); extern tree binfo_for_vtable PARAMS ((tree)); extern tree binfo_from_vbase PARAMS ((tree)); extern tree dfs_walk PARAMS ((tree, - tree (*)(tree, void *), + tree (*) (tree, void *), tree (*) (tree, void *), void *)); extern tree dfs_walk_real PARAMS ((tree, diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d68c300e2bc..4d1867d1366 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12137,9 +12137,7 @@ grok_ctor_properties (ctype, decl) other parameters have default arguments. */ if (TREE_CODE (parmtype) == REFERENCE_TYPE && TYPE_MAIN_VARIANT (TREE_TYPE (parmtype)) == ctype - && (TREE_CHAIN (parmtypes) == NULL_TREE - || TREE_CHAIN (parmtypes) == void_list_node - || TREE_PURPOSE (TREE_CHAIN (parmtypes))) + && sufficient_parms_p (TREE_CHAIN (parmtypes)) && !(DECL_TEMPLATE_INSTANTIATION (decl) && is_member_template (DECL_TI_TEMPLATE (decl)))) { @@ -12163,9 +12161,7 @@ grok_ctor_properties (ctype, decl) existence. Theoretically, they should never even be instantiated, but that's hard to forestall. */ else if (TYPE_MAIN_VARIANT (parmtype) == ctype - && (TREE_CHAIN (parmtypes) == NULL_TREE - || TREE_CHAIN (parmtypes) == void_list_node - || TREE_PURPOSE (TREE_CHAIN (parmtypes))) + && sufficient_parms_p (TREE_CHAIN (parmtypes)) && !(DECL_TEMPLATE_INSTANTIATION (decl) && is_member_template (DECL_TI_TEMPLATE (decl)))) {