aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2005-03-17 14:37:04 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2005-03-17 14:37:04 +0000
commitf2a79152758d093db319e0e87acee11f87796ce6 (patch)
tree698a20e4c2288d95d8b23329b6e8d3f3b13ced8b /gcc/cp/decl.c
parent3bd62c453dbd6b0b17a431d9f1231017c25ca3a3 (diff)
downloadgcc-f2a79152758d093db319e0e87acee11f87796ce6.zip
gcc-f2a79152758d093db319e0e87acee11f87796ce6.tar.gz
gcc-f2a79152758d093db319e0e87acee11f87796ce6.tar.bz2
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
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c27
1 files changed, 13 insertions, 14 deletions
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. */