]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
warn when mixing different bitops without parenthesis around them
authorWolfgang Bumiller <wry.git@bumiller.com>
Thu, 29 Aug 2013 06:18:06 +0000 (08:18 +0200)
committerWolfgang Bumiller <wry.git@bumiller.com>
Thu, 29 Aug 2013 06:18:06 +0000 (08:18 +0200)
parser.c

index 2277abf2b44f847b284dab87757d5ba0e5c0a7c4..92301d417f73fc3917b2f31e7ba09e574e2e501c 100644 (file)
--- 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) ) )