103 static void match_binop(struct expression *expr)
104 {
105 if (expr->op != '&')
106 return;
107 if (expr->left->op == '!')
108 sm_warning("add some parenthesis here?");
109 }
110
111 static void match_mask(struct expression *expr)
112 {
113 if (expr->op != '&')
114 return;
115 if (expr->right->type != EXPR_BINOP)
116 return;
117 if (expr->right->op != SPECIAL_RIGHTSHIFT)
118 return;
119
120 sm_warning("shift has higher precedence than mask");
121 }
122
123 static void match_subtract_shift(struct expression *expr)
124 {
125 if (expr->op != SPECIAL_LEFTSHIFT)
126 return;
127 if (expr->right->type != EXPR_BINOP)
128 return;
129 if (expr->right->op != '-')
130 return;
131 sm_warning("subtract is higher precedence than shift");
132 }
133
134 void check_precedence(int id)
135 {
136 my_id = id;
137
138 add_hook(&match_condition, CONDITION_HOOK);
139 add_hook(&match_binop, BINOP_HOOK);
140 add_hook(&match_mask, BINOP_HOOK);
141 add_hook(&match_subtract_shift, BINOP_HOOK);
142 }
|
103 static void match_binop(struct expression *expr)
104 {
105 if (expr->op != '&')
106 return;
107 if (expr->left->op == '!')
108 sm_warning("add some parenthesis here?");
109 }
110
111 static void match_mask(struct expression *expr)
112 {
113 if (expr->op != '&')
114 return;
115 if (expr->right->type != EXPR_BINOP)
116 return;
117 if (expr->right->op != SPECIAL_RIGHTSHIFT)
118 return;
119
120 sm_warning("shift has higher precedence than mask");
121 }
122
123 static void match_mask_compare(struct expression *expr)
124 {
125 if (expr->op != '&')
126 return;
127 if (expr->right->type != EXPR_COMPARE)
128 return;
129
130 sm_warning("compare has higher precedence than mask");
131 }
132
133 static void match_subtract_shift(struct expression *expr)
134 {
135 if (expr->op != SPECIAL_LEFTSHIFT)
136 return;
137 if (expr->right->type != EXPR_BINOP)
138 return;
139 if (expr->right->op != '-')
140 return;
141 sm_warning("subtract is higher precedence than shift");
142 }
143
144 void check_precedence(int id)
145 {
146 my_id = id;
147
148 add_hook(&match_condition, CONDITION_HOOK);
149 add_hook(&match_binop, BINOP_HOOK);
150 add_hook(&match_mask, BINOP_HOOK);
151 add_hook(&match_mask_compare, BINOP_HOOK);
152 add_hook(&match_subtract_shift, BINOP_HOOK);
153 }
|