From f2a79152758d093db319e0e87acee11f87796ce6 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 17 Mar 2005 14:37:04 +0000 Subject: re PR c++/19966 (Misleading message "must take exactly one argument") 2005-03-17 Paolo Carlini 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 | 8 ++++++++ gcc/cp/cp-tree.h | 2 +- gcc/cp/decl.c | 27 +++++++++++++-------------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 411d81c..85ce155 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2005-03-17 Paolo Carlini + + 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 PR c++/20186 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 640d4dd..466d4dd 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 4e350c3..d91b6ff 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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; } /* Return a string giving the keyword associate with CODE. */ -- cgit v1.1