From: Manuel López-Ibáñez Date: Mon, 5 Nov 2007 10:03:04 +0000 (+0000) Subject: typeck.c (build_binary_op): Use pedwarn instead of error for consistency. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=278b63df6234b1289a868d6e517a4ba52066f1a9;p=gcc.git typeck.c (build_binary_op): Use pedwarn instead of error for consistency. 2007-11-05 Manuel Lopez-Ibanez cp/ * typeck.c (build_binary_op): Use pedwarn instead of error for consistency. testsuite/ * g++dg/warn/pointer-integer-comparison.C: New. From-SVN: r129898 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 78697654c5c..78ff8f8e48e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2007-11-05 Manuel Lopez-Ibanez + + * typeck.c (build_binary_op): Use pedwarn instead of error for + consistency. + 2007-11-05 Jakub Jelinek PR c++/33836 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index c31a7a8ed45..17bb6b68ce0 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3357,12 +3357,12 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) { result_type = type0; - error ("ISO C++ forbids comparison between pointer and integer"); + pedwarn ("ISO C++ forbids comparison between pointer and integer"); } else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE) { result_type = type1; - error ("ISO C++ forbids comparison between pointer and integer"); + pedwarn ("ISO C++ forbids comparison between pointer and integer"); } else if (TYPE_PTRMEMFUNC_P (type0) && null_ptr_cst_p (op1)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f8f4ed13ae0..6817e837aab 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2007-11-05 Manuel Lopez-Ibanez + + * g++dg/warn/pointer-integer-comparison.C: New. + 2007-11-05 Jakub Jelinek PR tree-optimization/33856 diff --git a/gcc/testsuite/g++.dg/warn/pointer-integer-comparison.C b/gcc/testsuite/g++.dg/warn/pointer-integer-comparison.C new file mode 100644 index 00000000000..48489ebcb8c --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pointer-integer-comparison.C @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-fsyntax-only -fpermissive" } + +int foo (int i, void *p) +{ + if (i == p) // { dg-warning "warning: ISO C.. forbids comparison between pointer and integer" } + return 0; + else if (i != p) // { dg-warning "warning: ISO C.. forbids comparison between pointer and integer" } + return 1; +} + +int bar (int i, void *p) +{ + if (i < p) // { dg-warning "warning: ISO C.. forbids comparison between pointer and integer" } + return 0; + else if (i >= p) // { dg-warning "warning: ISO C.. forbids comparison between pointer and integer" } + return 1; +} + +int baz (int i, void *p) +{ + if (i <= p) // { dg-warning "warning: ISO C.. forbids comparison between pointer and integer" } + return 0; + else if (i > p) // { dg-warning "warning: ISO C.. forbids comparison between pointer and integer" } + return 1; +}