Re: [cocci] Reconsidering source code search challenges for nested compound statements

Markus Elfring <[email protected]> Sun, 8 Mar 2026 19:30:19 +0100
Newsgroups fr.inria.cocci
Message-ID <[email protected]>
>>>> @display2@
>>>> declaration d;
>>>> statement list sl;
>>>> @@
>>>>  {
>>>>  d
>>>> *sl
>>>>  }
>>>>
>>>>
>>>> Another questionable test result:
>>>> Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch test-item_assignments.c ../janitor/show_compound_statements2.cocci
>>>
>>> And I should know what test-item_assignments.c is?
>>
>> Reminder:
>> This can be possible.
>> https://lore.kernel.org/cocci/[email protected]/
>> https://sympa.inria.fr/sympa/arc/cocci/2026-03/msg00014.html
>>
>>
>> void my_test(void)
>> {
>>  int item;
>>
>>  if (1)
>>  {
>>     item = 1;
>>  }
>>
>>  item = 2;
>> }
> 
> A statement list metavariable only matches the code starting right after a
> {.  It can't start in random places.

Interesting …


>                                       Nothing is going to chenge here.

Will it matter then to mention for a better software documentation
if declarations would be skipped (or not)?
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/233b5ceb1d5a701fb270ebdf0a9bd6be0a6ce53b/docs/manual/cocci_syntax.tex#L348-350

Regards,
Markus