summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-14 18:37:37 +0000
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-14 18:37:37 +0000
commitf092582b2ade55c20811f1e42d28ceea856a5ca8 (patch)
tree3902ec91fa2cdd2dad08ffe58ff337ca6695c6dc /gcc/c-common.c
parent72d997cbf771c1c1b7ca60291da99dbb65b36205 (diff)
downloadgcc-f092582b2ade55c20811f1e42d28ceea856a5ca8.tar.gz
2007-03-14 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c/21438 * c-common.h (warn_for_div_by_zero): Declare. * c-common.c (warn_for_div_by_zero): Define. * c-typeck.c (build_binary_op): Call warn_for_div_zero instead of warning. cp/ * typeck.c (build_binary_op): Call warn_for_div_zero instead of warning. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122925 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 6543bd0f1b7..f82a84b5914 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -7032,4 +7032,17 @@ c_build_cdtor_fns (void)
struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
#endif
+/* Warn for division by zero according to the value of DIVISOR. */
+
+void
+warn_for_div_by_zero (tree divisor)
+{
+ /* If DIVISOR is zero, and has integral type, issue a warning about
+ division by zero. Do not issue a warning if DIVISOR has a
+ floating-point type, since we consider 0.0/0.0 a valid way of
+ generating a NaN. */
+ if (skip_evaluation == 0 && integer_zerop (divisor))
+ warning (OPT_Wdiv_by_zero, "division by zero");
+}
+
#include "gt-c-common.h"