Re: [PATCH] Use positional_argument in callback_only attribute handler
Jakub Jelinek <[email protected]>
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <anXCk2uu3vZcwy-g@tucnak> |
On Mon, Aug 03, 2026 at 04:13:02PM +0200, Josef Melcr wrote: > This patch replaces some of the manual bounds checking done in the > callback_only attribute handler with calls to positional_argument. > Since positional_argument issues warnings and the attribute handler > issues errors, I decided to downgrade the errors to warnings for > consistency. > > gcc/c-family/ChangeLog: > > * c-attribs.cc (handle_callback_only_attribute): Use > positional_argument for bounds checking in callback_only > attribute handler, downgrade errors to warnings for > consistency. > > gcc/testsuite/ChangeLog: > > * gcc.dg/attr-callback.c: Expect warnings instead of errors, > adjust expected messages. > > Signed-off-by: Josef Melcr <[email protected]> LGTM, except a nit. > if (!types_compatible_p (expected_type, arg_type)) > { > - error_at (DECL_SOURCE_LOCATION (decl), > - "argument type at index %d is not compatible with callback " > - "argument type at index %d", > - arg_idx + 1, curr + 1); > + warning_at ( > + DECL_SOURCE_LOCATION (decl), OPT_Wattributes, > + "argument type at index %d is not compatible with callback " > + "argument type at index %d", > + arg_idx + 1, curr + 1); Please avoid formatting like this unless really necessary (too long function name and no way to easily fit it). In this case, warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes, "argument type at index %d is not compatible with " "callback argument type at index %d", arg_idx + 1, curr + 1); fits just fine. Jakub