From: Dan Carpenter <dan.carpenter@oracle.com>
To: John Levon <levon@movementarian.org>
Cc: smatch@vger.kernel.org, linux-sparse@vger.kernel.org,
yuri.pankov@nexenta.com
Subject: Re: noreturn attribute doesn't work in smatch
Date: Thu, 22 Aug 2019 16:30:34 +0300 [thread overview]
Message-ID: <20190822132800.GJ4451@kadam> (raw)
In-Reply-To: <20190815111237.GA20100@movementarian.org>
On Thu, Aug 15, 2019 at 12:12:37PM +0100, John Levon wrote:
>
> I took another pass, and this works for me:
>
> diff --git a/parse.c b/parse.c
> index ca4726b8..44c59707 100644
> --- a/parse.c
> +++ b/parse.c
> @@ -2859,6 +2859,7 @@ struct token *external_declaration(struct token
> *token, struct symbol_list **lis
> /* Parse declaration-specifiers, if any */
> token = declaration_specifiers(token, &ctx);
> mod = storage_modifiers(&ctx);
> + mod |= ctx.ctype.modifiers & MOD_NORETURN;
> decl = alloc_symbol(token->pos, SYM_NODE);
> /* Just a type declaration? */
> if (match_op(token, ';')) {
>
> (I suppose a proper fix would collate all function-level attributes
> but...)
>
This patch seems like a hack, but I will apply it...
>
> However, it seems like smatch is still not quite passing its knowledge
> along: if I have:
>
> extern void die() __attribute((__noreturn__));
>
> void mydie()
> {
> die();
> }
>
> then the die() call is nullified, but smatch doesn't realise that means
> all paths of mydie() are __noreturn__ too.
The code to handle that is really ancient. You need to do:
./smatch --info test.c | tee warns.txt
grep no_return_funcs warns.txt || echo FAIL
./smatch_scripts/gen_no_return_funcs.sh warns.txt -p=levon
mv levon.no_return_funcs smatch_data/
Then pass -p=levon to smatch on the next run.
regards,
dan carpenter
next prev parent reply other threads:[~2019-08-22 13:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-15 0:53 noreturn attribute doesn't work in smatch John Levon
2019-08-15 11:12 ` John Levon
2019-08-22 13:30 ` Dan Carpenter [this message]
2019-08-22 13:46 ` John Levon
2019-08-22 15:05 ` Dan Carpenter
2019-08-22 15:29 ` John Levon
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=20190822132800.GJ4451@kadam \
--to=dan.carpenter@oracle.com \
--cc=levon@movementarian.org \
--cc=linux-sparse@vger.kernel.org \
--cc=smatch@vger.kernel.org \
--cc=yuri.pankov@nexenta.com \
/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