1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
# expression is treated as X != 0 ---------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if raw[0];
}
EOF
match 0:0:8=0x00 action 0
match action 1
# !expression is treated as X == 0 --------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if !raw[0];
}
EOF
match 0:0:8=0x00 action 1
match action 0
# -Wexpensive detects implicit X != 0 -----------------------------------------
tcc -Wexpensive -Wexperror 2>&1 >/dev/null
prio {
class if raw[0];
}
EOF
ERROR
negation is an "expensive" operation
# implicit X == 0 passes -Wexppostopt -----------------------------------------
tcc -Wexppostopt -Wexperror >/dev/null
prio {
class if !raw[0];
}
EOF
# single bit is handled efficiently -------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if raw[0] & 4;
}
EOF
match 0:5:1=0x1 action 1
match action 0
# -Wexppostopt acknowledges this ----------------------------------------------
tcc -Wexppostopt -Wexperror >/dev/null
prio {
class if raw[0] & 4;
}
EOF
# single bit is handled efficiently (negation) --------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if !(raw[0] & 4);
}
EOF
match 0:5:1=0x0 action 1
match action 0
# multi-bit tests are not efficient -------------------------------------------
tcc -Wexpensive -Wexperror 2>&1 >/dev/null
prio {
class if raw[0] & 6;
}
EOF
ERROR
negation is an "expensive" operation
|