.\" Please adjust this date whenever revising the manpage.
-.Dd December 7, 2008
+.Dd December 9, 2008
.Dt CPARSER 1
.Sh NAME
.Nm cparser
Warn if && without parentheses is used within ||, e.g. if\ (x\ ||\ y\ &&\ z).
Warn if it there may be confusion which 'if'-statement an 'else'-branch belongs to, e.g. if\ (x)\ if\ (y)\ {}\ else\ {}.
Warn if cascaded comparisons appear which do not have their mathematical meaning, e.g. if\ (23\ <=\ x\ <\ 42).
+Warn if + or - is used as operand of << or >>, e.g. x\ +\ y\ <<\ z.
.It Fl Wredundant-decls
Warn about redundant declarations, i.e. multiple declarations of the same object or static forward declarations which have no use before their definition.
.It Fl Wunreachable-code
warn_div_by_zero(expression);
}
+static void warn_addsub_in_shift(const expression_t *const expr)
+{
+ char op;
+ switch (expr->kind) {
+ case EXPR_BINARY_ADD: op = '+'; break;
+ case EXPR_BINARY_SUB: op = '-'; break;
+ default: return;
+ }
+
+ warningf(&expr->base.source_position,
+ "suggest parentheses around '%c' inside shift", op);
+}
+
static void semantic_shift_op(binary_expression_t *expression)
{
expression_t *const left = expression->left;
return;
}
+ if (warning.parentheses) {
+ warn_addsub_in_shift(left);
+ warn_addsub_in_shift(right);
+ }
+
type_left = promote_integer(type_left);
type_right = promote_integer(type_right);