re PR c++/19966 (Misleading message "must take exactly one argument")
authorPaolo Carlini <pcarlini@suse.de>
Thu, 17 Mar 2005 14:37:04 +0000 (14:37 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 17 Mar 2005 14:37:04 +0000 (14:37 +0000)
2005-03-17  Paolo Carlini  <pcarlini@suse.de>

PR c++/19966
* cp-tree.h (grok_op_properties): Change return type to void.
* decl.c (grok_op_properties): Return early - don't check the
arity - in case of a static member or an operator that cannot
be non-member; tidy a bit.

From-SVN: r96609

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

index 411d81ca760749b3c1ea9295c46156a5d1c8b241..85ce155906e06de82327da9fd5cb35aa2036bb88 100644 (file)
@@ -1,3 +1,11 @@
+2005-03-17  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/19966
+       * cp-tree.h (grok_op_properties): Change return type to void.
+       * decl.c (grok_op_properties): Return early - don't check the
+       arity - in case of a static member or an operator that cannot
+       be non-member; tidy a bit.
+
 2005-03-17  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/20186
index 640d4dd10a359bbfe20357c2f6b5e1eff752a841..466d4dd8e8c21dadf32e63549db1994d3240bb6d 100644 (file)
@@ -3795,7 +3795,7 @@ extern int copy_fn_p                              (tree);
 extern tree get_scope_of_declarator             (const cp_declarator *);
 extern void grok_special_member_properties     (tree);
 extern int grok_ctor_properties                        (tree, tree);
-extern bool grok_op_properties                 (tree, int, bool);
+extern void grok_op_properties                 (tree, int, bool);
 extern tree xref_tag                           (enum tag_types, tree, tag_scope, bool);
 extern tree xref_tag_from_type                 (tree, tree, tag_scope);
 extern void xref_basetypes                     (tree, tree);
index 4e350c348efff9698747bc5a09bb4ee8ce3d8c0f..d91b6ff302c4447879d82497f6fb374c314e2fee 100644 (file)
@@ -8648,11 +8648,10 @@ unary_op_p (enum tree_code code)
          || code == TYPE_EXPR);
 }
 
-/* DECL is a declaration for an overloaded operator.  Returns true if
-   the declaration is valid; false otherwise.  If COMPLAIN is true,
+/* DECL is a declaration for an overloaded operator.  If COMPLAIN is true,
    errors are issued for invalid declarations.  */
 
-bool
+void
 grok_op_properties (tree decl, int friendp, bool complain)
 {
   tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));
@@ -8661,10 +8660,6 @@ grok_op_properties (tree decl, int friendp, bool complain)
   tree name = DECL_NAME (decl);
   enum tree_code operator_code;
   int arity;
-  bool ok;
-
-  /* Assume that the declaration is valid.  */
-  ok = true;
 
   /* Count the number of arguments.  */
   for (argtype = argtypes, arity = 0;
@@ -8762,14 +8757,20 @@ grok_op_properties (tree decl, int friendp, bool complain)
              || operator_code == COMPONENT_REF
              || operator_code == ARRAY_REF
              || operator_code == NOP_EXPR)
-           error ("%qD must be a nonstatic member function", decl);
+           {
+             error ("%qD must be a nonstatic member function", decl);
+             return;
+           }
          else
            {
              tree p;
 
              if (DECL_STATIC_FUNCTION_P (decl))
-               error ("%qD must be either a non-static member "
-                       "function or a non-member function", decl);
+               {
+                 error ("%qD must be either a non-static member "
+                        "function or a non-member function", decl);
+                 return;
+               }
 
              for (p = argtypes; p && p != void_list_node; p = TREE_CHAIN (p))
                {
@@ -8784,12 +8785,11 @@ grok_op_properties (tree decl, int friendp, bool complain)
              if (!p || p == void_list_node)
                {
                  if (!complain)
-                   return false;
+                   return;
 
                  error ("%qD must have an argument of class or "
                         "enumerated type",
                         decl);
-                 ok = false;
                }
            }
        }
@@ -8797,7 +8797,7 @@ grok_op_properties (tree decl, int friendp, bool complain)
       /* There are no restrictions on the arguments to an overloaded
         "operator ()".  */
       if (operator_code == CALL_EXPR)
-       return ok;
+       return;
 
       if (IDENTIFIER_TYPENAME_P (name) && ! DECL_TEMPLATE_INFO (decl))
        {
@@ -8982,7 +8982,6 @@ grok_op_properties (tree decl, int friendp, bool complain)
 
     }
 
-  return ok;
 }
 \f
 /* Return a string giving the keyword associate with CODE.  */