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
This commit is contained in:
Dirk Mueller 2006-02-07 19:41:14 +00:00 committed by Dirk Mueller
parent 7135d758bc
commit 1104b28bc8
8 changed files with 35 additions and 9 deletions

View File

@ -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

View File

@ -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;

View File

@ -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++

View File

@ -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

View File

@ -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)
{

View File

@ -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

View File

@ -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;
}

View File

@ -0,0 +1,8 @@
// { dg-options "-Wno-div-by-zero" }
int breakme()
{
int x = 0;
x /= 0;
return x;
}