quals = TYPE_UNQUALIFIED;
}
- if (IDENTIFIER_OPNAME_P (DECL_NAME (decl)))
- grok_op_properties (decl, /*complain=*/true);
+ if (IDENTIFIER_OPNAME_P (DECL_NAME (decl))
+ && !grok_op_properties (decl, /*complain=*/true))
+ return NULL_TREE;
if (ctype && decl_function_context (decl))
DECL_NO_STATIC_CHAIN (decl) = 1;
tree arg_type;
int result = 1;
- if (!DECL_FUNCTION_MEMBER_P (d))
- /* Non-members are invalid. We complained, but kept the declaration. */
- return 0;
+ gcc_assert (DECL_FUNCTION_MEMBER_P (d));
if (TREE_CODE (d) == TEMPLATE_DECL
|| (DECL_TEMPLATE_INFO (d)
/* DECL is a declaration for an overloaded operator. If COMPLAIN is true,
errors are issued for invalid declarations. */
-void
+bool
grok_op_properties (tree decl, bool complain)
{
tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));
if (DECL_NAMESPACE_SCOPE_P (decl))
{
if (CP_DECL_CONTEXT (decl) != global_namespace)
- error ("%qD may not be declared within a namespace", decl);
+ {
+ error ("%qD may not be declared within a namespace", decl);
+ return false;
+ }
else if (!TREE_PUBLIC (decl))
- error ("%qD may not be declared as static", decl);
+ {
+ error ("%qD may not be declared as static", decl);
+ return false;
+ }
}
}
|| operator_code == NOP_EXPR)
{
error ("%qD must be a nonstatic member function", decl);
- return;
+ return false;
}
else
{
{
error ("%qD must be either a non-static member "
"function or a non-member function", decl);
- return;
+ return false;
}
for (p = argtypes; p && p != void_list_node; p = TREE_CHAIN (p))
{
tree arg = non_reference (TREE_VALUE (p));
if (arg == error_mark_node)
- return;
+ return false;
/* IS_AGGR_TYPE, rather than CLASS_TYPE_P, is used
because these checks are performed even on
if (!p || p == void_list_node)
{
- if (!complain)
- return;
-
- error ("%qD must have an argument of class or "
- "enumerated type",
- decl);
+ if (complain)
+ error ("%qD must have an argument of class or "
+ "enumerated type", decl);
+ return false;
}
}
}
/* There are no restrictions on the arguments to an overloaded
"operator ()". */
if (operator_code == CALL_EXPR)
- return;
+ return true;
/* Warn about conversion operators that will never be used. */
if (IDENTIFIER_TYPENAME_P (name)
{
/* 13.4.0.3 */
error ("ISO C++ prohibits overloading operator ?:");
+ return false;
}
else if (ellipsis_p)
- error ("%qD must not have variable number of arguments", decl);
+ {
+ error ("%qD must not have variable number of arguments", decl);
+ return false;
+ }
else if (ambi_op_p (operator_code))
{
if (arity == 1)
{
if (methodp)
error ("postfix %qD must take %<int%> as its argument",
- decl);
+ decl);
else
- error
- ("postfix %qD must take %<int%> as its second argument",
- decl);
+ error ("postfix %qD must take %<int%> as its second "
+ "argument", decl);
+ return false;
}
}
else
error ("%qD must take either zero or one argument", decl);
else
error ("%qD must take either one or two arguments", decl);
+ return false;
}
/* More Effective C++ rule 6. */
error ("%qD must take %<void%>", decl);
else
error ("%qD must take exactly one argument", decl);
+ return false;
}
}
else /* if (binary_op_p (operator_code)) */
error ("%qD must take exactly one argument", decl);
else
error ("%qD must take exactly two arguments", decl);
+ return false;
}
/* More Effective C++ rule 7. */
pedwarn ("%qD cannot have default arguments", decl);
}
else
- error ("%qD cannot have default arguments", decl);
+ {
+ error ("%qD cannot have default arguments", decl);
+ return false;
+ }
}
-
}
-
+ return true;
}
\f
/* Return a string giving the keyword associate with CODE. */