Hi All,
I do have trouble to write an semantic patch:
I want to remove the "double break" and add an "else"
in the following switch:
int main(void) {
int v = 3;
int a = 0;
int g = 8;
switch (v) {
case 1:
case 2:
if (a>0) {
g = g*2;
break;
}
g = g +1;
break;
default:
g= 0;
break;
}
return 0;
}
thus obtain:
int main(void) {
int v = 3;
int a = 0;
int g = 8;
switch (v) {
case 1:
case 2:
if (a>0) {
g = g*2;
} else {
g = g +1;
}
break;
default:
g= 0;
break;
}
return 0;
}
The following semantic fails to do that (else is not added)
and I don't know why...
@nodoublebreak@
expression x, e, f;
position p;
@@
switch (e) {
case x :
...
if (f) {
...
- br...@p;
- }
+ }
+ else {
...
+ }
break;
...
}
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)