Re: [cocci] Reconsidering source code search challenges for nested compound statements
Julia Lawall <[email protected]> Sun, 8 Mar 2026 14:24:53 +0100 (CET)
| Newsgroups | fr.inria.cocci |
|---|---|
| Message-ID | <[email protected]> |
On Sun, 8 Mar 2026, Markus Elfring wrote:
> > I constructed another source file example together with a corresponding SmPL script.
>
> @display@
> statement list sl;
> @@
> *{ sl }
>
>
> Compound statements are often used in known programming languages.
> https://en.cppreference.com/w/c/language/statements.html#Compound_statements
>
> Another test result:
> Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch test-item_assignments.c ../janitor/show_compound_statements.cocci
> …
> @@ -3,9 +3,6 @@ void my_test(void)
> int item;
>
> if (1)
> - {
> - item = 1;
> - }
>
> item = 2;
> }
>
>
> The source code search pattern looks promising (in principle).
> But it can be ambiguous in its minimal form.
> Thus further case distinctions would occasionally be helpful.
>
> Additional context information can become relevant then.
> How would you prefer to handle control flow recursion in safer ways here?
I have no idea what result you would like to see. The whole point of
Coccinelle is that if some context information should be taken into
account, then you can provide it.
julia
>
> Regards,
> Markus
>