If you put switch (...) { ... } it shouldn't matter about case or default.

How does this opinion fit to the following analysis result?


elfring@Sonne:~/Projekte/Coccinelle/Probe> SRC=assign-test1.c && cat $SRC && LINE='-----' && for PAT in assignment_pattern3.cocci assignment_pattern4.cocci; do echo $LINE && cat $PAT && echo $LINE && spatch -sp_file $PAT $SRC; done
int my_value(void)
{
  return 1;
}

int main(void)
{
  int x = my_value();
}
-----
@is_assigned@
position p;
expression x, y;
type t;
@@
 y@p = (t) x(...)
 ... when != switch (<+...y...+>) { ... }

@is_assigned_without_when_filter@
position p != is_assigned.p;
expression x, y;
type t;
@@
*y@p = (t) x(...)
-----
init_defs_builtins: /usr/share/coccinelle/standard.h
108 111
Fatal error: exception Failure("minus: parse error:
 = File "assignment_pattern3.cocci", line 7, column 36,  charpos = 108
    around = '...', whole content =  ... when != switch (<+...y...+>) { ... }
")
-----
@is_assigned@
position p;
expression x, y;
type t;
statement s;
@@
 y@p = (t) x(...)
 ... when != switch (<+...y...+>) s

@is_assigned_without_when_filter@
position p != is_assigned.p;
expression x, y;
type t;
@@
*y@p = (t) x(...)
-----
init_defs_builtins: /usr/share/coccinelle/standard.h
119 120
Fatal error: exception Failure("minus: parse error:
 = File "assignment_pattern4.cocci", line 8, column 34,  charpos = 119
    around = 's', whole content =  ... when != switch (<+...y...+>) s
")


The grammar contains the following specification for the semantic patch language so far.
http://coccinelle.lip6.fr/docs/main_grammar008.html
...
|       switch ([dot_expr]) {case_line * }
...


Would you like to adjust the handling of switch statements in SmPL?
http://msdn.microsoft.com/en-us/library/66k51h7a.aspx
http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V50_HTML/ARH9NATE/DOCU_017.HTM#switch_sec
http://www.cs.wmich.edu/~gupta/teaching/cs4850/sumII06/The%20syntax%20of%20C%20in%20Backus-Naur%20form.htm

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to