From f140c3906353577bcf3fe584cf9ee5beff639132 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 29 Aug 2013 08:18:06 +0200 Subject: [PATCH] warn when mixing different bitops without parenthesis around them --- parser.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/parser.c b/parser.c index 2277abf..92301d4 100644 --- a/parser.c +++ b/parser.c @@ -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) ) ) -- 2.39.2