+2015-01-07 Marek Polacek <polacek@redhat.com>
+
+ PR c/64440
+ * c-common.c (c_fully_fold_internal): Warn for division and modulo
+ if orig_op1 isn't INTEGER_CST, op1 is INTEGER_CST and is zero.
+
2015-01-05 Trevor Saunders <tsaunders@mozilla.com>
PR c++/31397
? G_("left shift count >= width of type")
: G_("right shift count >= width of type")));
}
+ if ((code == TRUNC_DIV_EXPR
+ || code == CEIL_DIV_EXPR
+ || code == FLOOR_DIV_EXPR
+ || code == EXACT_DIV_EXPR
+ || code == TRUNC_MOD_EXPR)
+ && TREE_CODE (orig_op1) != INTEGER_CST
+ && TREE_CODE (op1) == INTEGER_CST
+ && (TREE_CODE (TREE_TYPE (orig_op0)) == INTEGER_TYPE
+ || TREE_CODE (TREE_TYPE (orig_op0)) == FIXED_POINT_TYPE)
+ && TREE_CODE (TREE_TYPE (orig_op1)) == INTEGER_TYPE)
+ warn_for_div_by_zero (loc, op1);
goto out;
case INDIRECT_REF:
+2015-01-07 Marek Polacek <polacek@redhat.com>
+
+ PR c/64440
+ * gcc.dg/pr64440.c: New test.
+ * c-c++-common/pr56607.c: Don't limit dg-warnings to C++.
+
2015-01-07 Marek Polacek <polacek@redhat.com>
PR c/64417
f2 (void)
{
const int x = sizeof (char) - 1;
- return 1 / x; /* { dg-warning "division by zero" "" { target c++ } } */
+ return 1 / x; /* { dg-warning "division by zero" } */
}
int
f4 (void)
{
const int x = sizeof (int) / 3 - 1;
- return 1 / x; /* { dg-warning "division by zero" "" { target c++ } } */
+ return 1 / x; /* { dg-warning "division by zero" } */
}
--- /dev/null
+/* PR c/64440 */
+/* { dg-do compile } */
+/* { dg-options "-Wall -O2" } */
+
+int
+foo (int x)
+{
+ const int y = 0;
+ int r = 0;
+ r += x / y; /* { dg-warning "division by zero" } */
+ r += x / 0; /* { dg-warning "division by zero" } */
+ r += x % y; /* { dg-warning "division by zero" } */
+ r += x % 0; /* { dg-warning "division by zero" } */
+ return r;
+}