cp-tree.h (sufficient_parms_p): Declare new function.
authorNathan Sidwell <nathan@codesourcery.com>
Thu, 7 Dec 2000 14:17:53 +0000 (14:17 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Thu, 7 Dec 2000 14:17:53 +0000 (14:17 +0000)
* 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.

From-SVN: r38111

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/decl.c

index e63dd3969092d6e4a342e4639ad8b7beda143888..923158ab373730f97c8fb5181335763935f8e31c 100644 (file)
@@ -1,3 +1,11 @@
+2000-12-07  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * 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  <jakub@redhat.com>
 
        * optimize.c (copy_body_r): Set STMT_IS_FULL_EXPR_P on EXPR_STMT.
index fd5f904638215c1214b8dcaf8f0f9d07555d34d9..cbe345a3f05961320f82bc5d8016d083c1b8e73f 100644 (file)
@@ -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);
 }
index 5b7eca90ac057988b455029c661c2c9ede36989d..9fcbcc2cff54946412701edc5a72e6c39d0be8fe 100644 (file)
@@ -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,
index d68c300e2bca25e2a55d1a16d12d087775a59434..4d1867d1366820b0be4dd64032096e51ebc8d210 100644 (file)
@@ -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))))
     {