diff options
author | Dirk Mueller <dmueller@suse.com> | 2006-02-07 19:41:14 +0000 |
---|---|---|
committer | Dirk Mueller <mueller@gcc.gnu.org> | 2006-02-07 19:41:14 +0000 |
commit | 1104b28bc84483a6e98335cc5369d089a56ec6ed (patch) | |
tree | 73d1c3e94726a3156bfd94997fc2db501ff46a43 | |
parent | 7135d758bcdd76d68aa660f9082969f3443e652a (diff) | |
download | gcc-1104b28bc84483a6e98335cc5369d089a56ec6ed.zip gcc-1104b28bc84483a6e98335cc5369d089a56ec6ed.tar.gz gcc-1104b28bc84483a6e98335cc5369d089a56ec6ed.tar.bz2 |
c.opt: C++ frontend supports -Wdiv-by-zero.
2006-02-07 Dirk Mueller <dmueller@suse.com>
* c.opt: C++ frontend supports -Wdiv-by-zero.
* c-opts.c (c_common_handle_option): Remove dead case.
* typeck.c (build_binary_op): Annotate div-by-zero
warnings to make -Wno-div-by-zero have an effect.
g++.dg/warn/Wdiv-by-zero.C: New test.
g++.dg/warn/Wno-div-by-zero.C: New.
From-SVN: r110712
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-opts.c | 4 | ||||
-rw-r--r-- | gcc/c.opt | 2 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wdiv-by-zero.C | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wno-div-by-zero.C | 8 |
8 files changed, 35 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1e11fb2..4946e3b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2006-02-07 Dirk Mueller <dmueller@suse.com> + + * c.opt: C++ frontend supports -Wdiv-by-zero. + * c-opts.c (c_common_handle_option): Remove dead case. + 2006-02-07 Eric Botcazou <ebotcazou@libertysurf.fr> * configure.ac (TLS assembler check): Do not enable TLS by diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 8c5827a..34fc6b9 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -431,10 +431,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) cpp_opts->warn_deprecated = value; break; - case OPT_Wdiv_by_zero: - warn_div_by_zero = value; - break; - case OPT_Wendif_labels: cpp_opts->warn_endif_labels = value; break; @@ -166,7 +166,7 @@ C++ ObjC++ Var(warn_deprecated) Init(1) Warn about deprecated compiler features Wdiv-by-zero -C ObjC Var(warn_div_by_zero) Init(1) +C ObjC C++ Var(warn_div_by_zero) Init(1) Warn about compile-time integer division by zero Weffc++ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cdfeaf3..8b0e9fc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2006-02-07 Dirk Mueller <dmueller@suse.com> + + * typeck.c (build_binary_op): Annotate div-by-zero + warnings to make -Wno-div-by-zero have an effect. + 2006-02-07 Mark Mitchell <mark@codesourcery.com> PR c++/9737 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 1fb3cbf..adac227 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2954,9 +2954,9 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, || code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)) { if (TREE_CODE (op1) == INTEGER_CST && integer_zerop (op1)) - warning (0, "division by zero in %<%E / 0%>", op0); + warning (OPT_Wdiv_by_zero, "division by zero in %<%E / 0%>", op0); else if (TREE_CODE (op1) == REAL_CST && real_zerop (op1)) - warning (0, "division by zero in %<%E / 0.%>", op0); + warning (OPT_Wdiv_by_zero, "division by zero in %<%E / 0.%>", op0); if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE) code0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0))); @@ -2991,9 +2991,9 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, case TRUNC_MOD_EXPR: case FLOOR_MOD_EXPR: if (code1 == INTEGER_TYPE && integer_zerop (op1)) - warning (0, "division by zero in %<%E %% 0%>", op0); + warning (OPT_Wdiv_by_zero, "division by zero in %<%E %% 0%>", op0); else if (code1 == REAL_TYPE && real_zerop (op1)) - warning (0, "division by zero in %<%E %% 0.%>", op0); + warning (OPT_Wdiv_by_zero, "division by zero in %<%E %% 0.%>", op0); if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c9e44af..e9fb7d1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-02-07 Dirk Mueller <dmueller@suse.com> + + g++.dg/warn/Wdiv-by-zero.C: New test. + g++.dg/warn/Wno-div-by-zero.C: New. + 2006-02-07 Jeff Law <law@redhat.com> * gcc.dg/tree-ssa/vrp01.c: Update dumpfile names now that we have diff --git a/gcc/testsuite/g++.dg/warn/Wdiv-by-zero.C b/gcc/testsuite/g++.dg/warn/Wdiv-by-zero.C new file mode 100644 index 0000000..7dc7766 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wdiv-by-zero.C @@ -0,0 +1,7 @@ +// test that division by zero warnings are enabled by default +int breakme() +{ + int x = 0; + x /= 0; // { dg-warning "division by" } + return x; +} diff --git a/gcc/testsuite/g++.dg/warn/Wno-div-by-zero.C b/gcc/testsuite/g++.dg/warn/Wno-div-by-zero.C new file mode 100644 index 0000000..937628e --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wno-div-by-zero.C @@ -0,0 +1,8 @@ +// { dg-options "-Wno-div-by-zero" } + +int breakme() +{ + int x = 0; + x /= 0; + return x; +} |