diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2007-03-14 18:37:37 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2007-03-14 18:37:37 +0000 |
commit | 2e9cb75ef7914a57214ae5b73bfa461030126dba (patch) | |
tree | 3902ec91fa2cdd2dad08ffe58ff337ca6695c6dc /gcc/c-common.c | |
parent | 925af765a6be182d51d7e1655f1f10c8a3bc30c3 (diff) | |
download | gcc-2e9cb75ef7914a57214ae5b73bfa461030126dba.zip gcc-2e9cb75ef7914a57214ae5b73bfa461030126dba.tar.gz gcc-2e9cb75ef7914a57214ae5b73bfa461030126dba.tar.bz2 |
re PR c/21438 (Warning about division by zero depends on lexical form)
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.
From-SVN: r122925
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 6543bd0..f82a84b 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" |