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
+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
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))
{
+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
--- /dev/null
+// { 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;
+}