> Yu can do whatever you want, but you will get lotsof false positives if > you keep it. If you really want a star on the declaration then you need > to make two rules. The first that finds the positions of the places that > match and the second that only puts a * when there is both a matched > declaration and a matched reinitialization.
I hoped that the following SmPL script variant can be another approximation for the desired solution on the discussed source code search pattern. @display@ binary operator bo1, bo2; expression action, e1, e2 != e1, e3, e4, e5; identifier var; statement es1, is2, es2, is3, es3; type t; @@ ( t var = e1; <+... if (...) { var = e2; ... } else es1 ...+> if ( \( var \| var bo1 e3 \) ) is2 else es2 | t var * = e1 ; ... when != if ( \( var \| var bo2 e4 \) ) is3 else es3 when != action(..., var, ...) when != switch (var) { default: ... } when exists ( *e5 = <+... var ...+> | *var = e5 ) ) But I stumble on the following error message. elfring@Sonne:~/Projekte/Linux/next-patched> git checkout next-20190620 && spatch drivers/misc/lkdtm/core.c ~/Projekte/Coccinelle/janitor/show_questionable_variable_initialisation5.cocci … minus: parse error: File "/home/elfring/Projekte/Coccinelle/janitor/show_questionable_variable_initialisation5.cocci", line 36, column 0, charpos = 492 around = ')', whole content = ) I observed then that each of the two main branches in the shown SmPL disjunction can work as expected. So I wonder even more why the combination can not be parsed by the software “Coccinelle 1.0.7-00211-geaa13d59 (OCaml 4.07.1)” so far. Regards, Markus _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci