Hi,
this patch cleans up two useless loops from the callback_only attribute
handler.
The first loop used to check for void_list_node, now it does
literally nothing. Seems like I forgot to remove it when I changed the
validation logic a few weeks ago.
The second loop also checks for void_list_node and decrements type_nargs
if it finds it, but since we ensure !stdarg_p for both the carrying and
the callback function, looking for void_list_node again is pointless.
In this case, we can just initialize type_nargs differently.
Bootstrapped and regtested on x86_64-linux with no new regressions. OK
for master?
Best regards,
Josef
gcc/c-family/ChangeLog:
* c-attribs.cc (handle_callback_only_attribute): Clean up old code.
Signed-off-by: Josef Melcr <[email protected]>
---
gcc/c-family/c-attribs.cc | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 54403011063..204055f6332 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -4716,10 +4716,6 @@ handle_callback_only_attribute (tree *node, tree name,
tree args,
DECL_ARGUMENTS returns NULL at this point. */
int callback_fn_idx = TREE_INT_CST_LOW (val);
tree decl_type_args = TYPE_ARG_TYPES (decl_type);
- tree it;
- for (it = decl_type_args; it != NULL_TREE; it = TREE_CHAIN (it))
- if (it == void_list_node)
- break;
if (callback_fn_idx == CB_UNKNOWN_POS)
{
@@ -4768,13 +4764,7 @@ handle_callback_only_attribute (tree *node, tree name,
tree args,
/* Compare the length of the list of argument indices
and the real number of parameters the callback takes. */
unsigned cfn_nargs = list_length (TREE_CHAIN (args));
- unsigned type_nargs = list_length (type_args);
- for (it = type_args; it != NULL_TREE; it = TREE_CHAIN (it))
- if (it == void_list_node)
- {
- --type_nargs;
- break;
- }
+ unsigned type_nargs = list_length (type_args) - 1;
if (cfn_nargs != type_nargs)
{
warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
@@ -4785,7 +4775,7 @@ handle_callback_only_attribute (tree *node, tree name,
tree args,
}
unsigned curr = 0;
- tree cfn_it;
+ tree it, cfn_it;
/* Validate type compatibility of the arguments passed
from caller function to callback. "it" is used to step
through the parameters of the caller, "cfn_it" is
--
2.55.0