warn when mixing different bitops without parenthesis around them

This commit is contained in:
Wolfgang Bumiller 2013-08-29 08:18:06 +02:00
parent 51ef277e21
commit f140c39063

View file

@ -1714,6 +1714,15 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma
}
}
if (olast &&
olast->id != op->id &&
(op->id == opid1('&') || op->id == opid1('|') || op->id == opid1('^')) &&
(olast->id == opid1('&') || olast->id == opid1('|') || olast->id == opid1('^')))
{
(void)!parsewarning(parser, WARN_PARENTHESIS, "suggesting parenthesis around bitwise operations");
warn_truthvalue = false;
}
while (olast && (
(op->prec < olast->prec) ||
(op->assoc == ASSOC_LEFT && op->prec <= olast->prec) ) )