tweak some pointer sema checking stuff (which was added to implement PR4175) to
avoid emitting a warning on "someptr > 0". This is obviously questionable (they
could use != instead) but is reasonable, and the warning "ordered comparison
between pointer and integer" didn't make a ton of sense because 0 is a valid
null pointer constant.
Just silence the warning in this case, it is unlikely to indicate a bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79743 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index b7c5c25..2afaab5 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -8,8 +8,7 @@
return C != 0;
}
-int equal(char *a, const char *b)
-{
+int equal(char *a, const char *b) {
return a == b;
}
@@ -18,21 +17,18 @@
return a == b; // expected-warning {{comparison of distinct pointer types}}
}
-int pointers(int *a)
-{
- return a > 0; // expected-warning {{ordered comparison between pointer and integer}}
+int pointers(int *a) {
+ return a > 0; // no warning. rdar://7163039
return a > (void *)0; // expected-warning {{comparison of distinct pointer types}}
}
-int function_pointers(int (*a)(int), int (*b)(int))
-{
+int function_pointers(int (*a)(int), int (*b)(int)) {
return a > b; // expected-warning {{ordered comparison of function pointers}}
return function_pointers > function_pointers; // expected-warning {{ordered comparison of function pointers}}
return a == (void *) 0;
return a == (void *) 1; // expected-warning {{comparison of distinct pointer types}}
}
-int void_pointers(void *foo)
-{
+int void_pointers(void *foo) {
return foo == NULL;
}