[Cocci] if else not matching
Derek M Jones
derek at knosof.co.uk
Mon Jun 29 17:53:02 CEST 2009
All,
Sorry for this email but I think I am doing something so basically
wrong I cannot see it (much more complicated examples such as
nested if else if match as expected). I am using version 0.1.8
and have been staring at this and trying different things for
several hours.
I would appreciate if somebody could put me out of my misery and
point out why the following pattern is not matching against the
very short C function appended at the end.
I don't get any warnings (or a --- ifelse)
@ if_else_1
disable neg_if
@
expression E_1_ie;
statement S_1_ie, S_2_ie;
position p_1_ie, p_2_ie;
@@
if at p_1_ie (E_1_ie)
S_1_ie
else at p_2_ie
S_2_ie
@
script:python @ expr_1_ie << if_else_1.E_1_ie;
loc_1_ie << if_else_1.p_1_ie;
loc_2_ie << if_else_1.p_2_ie;
@@
print "--- ifelse"
print loc_1_ie[0].line, " ", loc_1_ie[0].column, " ", expr_1_ie
print loc_2_ie[0].line, " ", loc_2_ie[0].column
the C input:
void f(void)
{
if (x2)
w++;
else
z--;
}
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:derek at knosof.co.uk
Source code analysis http://www.knosof.co.uk
More information about the Cocci
mailing list