>> @@
>> -rc = x;
>
> Replace by - lrc@rc = x;

I have constructed the following test script for the semantic patch language.

@check1@
expression x;
identifier rc;
local idexpression lrc;
position p;
@@
 lrc@rc = x@p;
 return lrc;

@check2@
identifier check1.rc;
position p;
type t;
@@
 t rc@p;
 ... when != rc

@script:python to_do1@
p << check1.p;
@@
coccilib.org.print_todo(p[0],
                        "WARNING: An expression was assigned to a local 
variable before it will be returned by the subsequent statement.")

@script:python to_do2@
p << check2.p;
v << check2.rc;
@@
coccilib.org.print_todo(p[0],
                        "INFO: May the local variable \""
                        + v
                        + "\" be deleted?")


I wonder about a corresponding test result.

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci 
move_code_to_return1.cocci
…
scriptmeta: semantic error: bad rule check2 or bad variable rc
  File "move_code_to_return1.cocci", line 26, column 14, charpos = 474
  around = ';',
  whole content = v << check2.rc;


I imagine that it would be easier to understand that the content from
the inherited metavariable can be directly used.
The SmPL specification “v << check1.rc;” gets accepted by Coccinelle software
and seems to work then in the way I would expect it also for the other script 
variant.
Will any more adjustments become relevant for such a source code search 
approach?

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to