Commit f2a79152 by Paolo Carlini Committed by Paolo Carlini

re PR c++/19966 (Misleading message "must take exactly one argument")

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
parent 3bd62c45
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> 2005-03-17 Nathan Sidwell <nathan@codesourcery.com>
PR c++/20186 PR c++/20186
......
...@@ -3795,7 +3795,7 @@ extern int copy_fn_p (tree); ...@@ -3795,7 +3795,7 @@ extern int copy_fn_p (tree);
extern tree get_scope_of_declarator (const cp_declarator *); extern tree get_scope_of_declarator (const cp_declarator *);
extern void grok_special_member_properties (tree); extern void grok_special_member_properties (tree);
extern int grok_ctor_properties (tree, 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 (enum tag_types, tree, tag_scope, bool);
extern tree xref_tag_from_type (tree, tree, tag_scope); extern tree xref_tag_from_type (tree, tree, tag_scope);
extern void xref_basetypes (tree, tree); extern void xref_basetypes (tree, tree);
......
...@@ -8648,11 +8648,10 @@ unary_op_p (enum tree_code code) ...@@ -8648,11 +8648,10 @@ unary_op_p (enum tree_code code)
|| code == TYPE_EXPR); || code == TYPE_EXPR);
} }
/* DECL is a declaration for an overloaded operator. Returns true if /* DECL is a declaration for an overloaded operator. If COMPLAIN is true,
the declaration is valid; false otherwise. If COMPLAIN is true,
errors are issued for invalid declarations. */ errors are issued for invalid declarations. */
bool void
grok_op_properties (tree decl, int friendp, bool complain) grok_op_properties (tree decl, int friendp, bool complain)
{ {
tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl)); tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));
...@@ -8661,10 +8660,6 @@ grok_op_properties (tree decl, int friendp, bool complain) ...@@ -8661,10 +8660,6 @@ grok_op_properties (tree decl, int friendp, bool complain)
tree name = DECL_NAME (decl); tree name = DECL_NAME (decl);
enum tree_code operator_code; enum tree_code operator_code;
int arity; int arity;
bool ok;
/* Assume that the declaration is valid. */
ok = true;
/* Count the number of arguments. */ /* Count the number of arguments. */
for (argtype = argtypes, arity = 0; for (argtype = argtypes, arity = 0;
...@@ -8762,14 +8757,20 @@ grok_op_properties (tree decl, int friendp, bool complain) ...@@ -8762,14 +8757,20 @@ grok_op_properties (tree decl, int friendp, bool complain)
|| operator_code == COMPONENT_REF || operator_code == COMPONENT_REF
|| operator_code == ARRAY_REF || operator_code == ARRAY_REF
|| operator_code == NOP_EXPR) || operator_code == NOP_EXPR)
{
error ("%qD must be a nonstatic member function", decl); error ("%qD must be a nonstatic member function", decl);
return;
}
else else
{ {
tree p; tree p;
if (DECL_STATIC_FUNCTION_P (decl)) if (DECL_STATIC_FUNCTION_P (decl))
{
error ("%qD must be either a non-static member " error ("%qD must be either a non-static member "
"function or a non-member function", decl); "function or a non-member function", decl);
return;
}
for (p = argtypes; p && p != void_list_node; p = TREE_CHAIN (p)) 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) ...@@ -8784,12 +8785,11 @@ grok_op_properties (tree decl, int friendp, bool complain)
if (!p || p == void_list_node) if (!p || p == void_list_node)
{ {
if (!complain) if (!complain)
return false; return;
error ("%qD must have an argument of class or " error ("%qD must have an argument of class or "
"enumerated type", "enumerated type",
decl); decl);
ok = false;
} }
} }
} }
...@@ -8797,7 +8797,7 @@ grok_op_properties (tree decl, int friendp, bool complain) ...@@ -8797,7 +8797,7 @@ grok_op_properties (tree decl, int friendp, bool complain)
/* There are no restrictions on the arguments to an overloaded /* There are no restrictions on the arguments to an overloaded
"operator ()". */ "operator ()". */
if (operator_code == CALL_EXPR) if (operator_code == CALL_EXPR)
return ok; return;
if (IDENTIFIER_TYPENAME_P (name) && ! DECL_TEMPLATE_INFO (decl)) if (IDENTIFIER_TYPENAME_P (name) && ! DECL_TEMPLATE_INFO (decl))
{ {
...@@ -8982,7 +8982,6 @@ grok_op_properties (tree decl, int friendp, bool complain) ...@@ -8982,7 +8982,6 @@ grok_op_properties (tree decl, int friendp, bool complain)
} }
return ok;
} }
/* Return a string giving the keyword associate with CODE. */ /* Return a string giving the keyword associate with CODE. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment