On Fri, May 24, 2019 at 3:12 PM Julia Lawall <[email protected]> wrote:
> You can't just put the header of an if.  You have to put the whole thing:
>
> if (x == NULL) S1 else S2

Ok that works.

Can the (|) expressions be nested?  I'm trying to match multiple
possibilities, and I can't really get them to work.  I need to match
multiple macro names (MACRO1, MACRO2, etc), and the typecast before
the macro call is optional (but should be preserved), and it should
ignore lines that already have a null-pointer check after them.

I came up with this, but it doesn't work:

@@
identifier func;
fresh identifier label = func ## "_exit";
type T;
expression x;
statement S;
@@
func(...) {
<+...
(
 x =
 (
  (T)
 |
 )
 (MACRO1|MACRO2|MACRO3)
 (...);
 if (x == NULL) S
|
 x =
 (
  (T)
 |
 )
 (MACRO1|MACRO2|MACRO3)
(...);
+if (x == NULL)
+{
+    status = ERROR;
+    goto label;
+}
)
...+>
}

I get:

minus: parse error:
  File "/home/ttabi/boardobj.cocci", line 14, column 1, charpos = 135
  around = '|',
  whole content =  |
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to