OSDN Git Service

2007-11-05 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Nov 2007 10:03:04 +0000 (10:03 +0000)
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Nov 2007 10:03:04 +0000 (10:03 +0000)
cp/
* typeck.c (build_binary_op): Use pedwarn instead of error for
consistency.
testsuite/
* g++dg/warn/pointer-integer-comparison.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129898 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pointer-integer-comparison.C [new file with mode: 0644]

index 7869765..78ff8f8 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-05  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       * typeck.c (build_binary_op): Use pedwarn instead of error for
+       consistency.
+
 2007-11-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/33836
index c31a7a8..17bb6b6 100644 (file)
@@ -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))
        {
index f8f4ed1..6817e83 100644 (file)
@@ -1,3 +1,7 @@
+2007-11-05  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       * g++dg/warn/pointer-integer-comparison.C: New.
+
 2007-11-05  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..48489eb
--- /dev/null
@@ -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;
+}