From: Julia Lawall <julia.lawall@inria.fr>
To: Anon Anonson <anon@chud.cyou>
Cc: cocci@inria.fr
Subject: Re: [cocci] Possible bug
Date: Mon, 15 Sep 2025 23:37:59 +0200 (CEST) [thread overview]
Message-ID: <a38c126f-8a35-343-f7d0-d2a0da17f521@inria.fr> (raw)
In-Reply-To: <d04274ea-7bff-4c63-8fc6-55a19ab45b55@chud.cyou>
[-- Attachment #1: Type: text/plain, Size: 1009 bytes --]
On Sun, 14 Sep 2025, Anon Anonson wrote:
> Greetings,
>
> I was playing around with spatch in an attempt to create a wrapper utility for renaming.
>
> Given the following script:
> @ rn_dec @
> type T;
> identifier I = i;
> @@
>
> - T I
> + T b
> ;
>
> And the following input:
> void f() {
> int i;
> for (int i;;) { ; }
> }
>
> The following patch is generated:
> diff =
> --- main.c
> +++ /tmp/cocci-output-9754-fec11b-main.c
> @@ -1,4 +1,4 @@
> void f() {
> - int i;
> + int b;
> for (int i;;) { ; }
> }
>
> However, I would expect the declaration inside the 'for' to be replaced too.
> My only questions is: is the observed behaviour intended?
I guess one could go either way on this. Normally, a for loop header has
the form
for ( ; ; )
So the semicolons are part of thr for loop header, not part of the
declaration. So that's why your pattern doesn't match. I think that
currently the only solution is to make a special case for for loop
headers.
julia
next prev parent reply other threads:[~2025-09-15 21:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-14 11:47 [cocci] Possible bug Anon Anonson
2025-09-15 21:37 ` Julia Lawall [this message]
2025-10-19 19:34 ` Anon Anonson
2025-09-16 8:00 ` [cocci] Renaming identifiers with SmPL Markus Elfring
2025-09-16 8:25 ` [cocci] Renaming identifiers with SmPL? Markus Elfring
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=a38c126f-8a35-343-f7d0-d2a0da17f521@inria.fr \
--to=julia.lawall@inria.fr \
--cc=anon@chud.cyou \
--cc=cocci@inria.fr \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).