Print this page
11506 smatch resync
@@ -118,10 +118,20 @@
return;
sm_warning("shift has higher precedence than mask");
}
+static void match_mask_compare(struct expression *expr)
+{
+ if (expr->op != '&')
+ return;
+ if (expr->right->type != EXPR_COMPARE)
+ return;
+
+ sm_warning("compare has higher precedence than mask");
+}
+
static void match_subtract_shift(struct expression *expr)
{
if (expr->op != SPECIAL_LEFTSHIFT)
return;
if (expr->right->type != EXPR_BINOP)
@@ -136,7 +146,8 @@
my_id = id;
add_hook(&match_condition, CONDITION_HOOK);
add_hook(&match_binop, BINOP_HOOK);
add_hook(&match_mask, BINOP_HOOK);
+ add_hook(&match_mask_compare, BINOP_HOOK);
add_hook(&match_subtract_shift, BINOP_HOOK);
}