From: Dan Carpenter <error27@gmail.com>
To: Dmitry Ilvokhin <d@ilvokhin.com>
Cc: Chris Li <sparse@chrisli.org>, linux-sparse@vger.kernel.org
Subject: Re: [PATCH] accept an empty attribute argument list
Date: Fri, 5 Jun 2026 18:26:44 +0300 [thread overview]
Message-ID: <aiLqtDvo5uzLfdak@stanley.mountain> (raw)
In-Reply-To: <20260605113045.483498-1-d@ilvokhin.com>
On Fri, Jun 05, 2026 at 11:30:45AM +0000, Dmitry Ilvokhin wrote:
> GCC and clang accept an empty argument list for attributes, e.g.
> __attribute__((nonnull())), and treat it the same as the bare
> __attribute__((nonnull)). sparse instead rejects it with
> "an expression is expected before ')'".
>
> ignore_attribute() and recover_unknown_attribute() consume the optional
> argument list with parens_expression(), which requires a non-empty
> expression, so an empty () is rejected. The bare form is fine because it
> takes no parentheses and skips that path.
>
> This turned up in the Linux kernel: the cleanup.h guard macros expand
> __nonnull_args() to __attribute__((__nonnull__())).
>
> https://lore.kernel.org/all/aiJi0WcYE8FZt-jO@stanley.mountain/
>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Signed-off-by: Dmitry Ilvokhin <d@ilvokhin.com>
> ---
> parse.c | 17 +++++++++++++----
> validation/attribute-nonnull-empty.c | 12 ++++++++++++
> 2 files changed, 25 insertions(+), 4 deletions(-)
> create mode 100644 validation/attribute-nonnull-empty.c
Thanks so much!
Tested-by: Dan Carpenter <error27@gmail.com>
regards,
dan carpenter
prev parent reply other threads:[~2026-06-05 15:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 11:30 [PATCH] accept an empty attribute argument list Dmitry Ilvokhin
2026-06-05 15:26 ` Dan Carpenter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aiLqtDvo5uzLfdak@stanley.mountain \
--to=error27@gmail.com \
--cc=d@ilvokhin.com \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox