summaryrefslogtreecommitdiff
path: root/test/Sema/compare.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-30 06:24:05 +0000
committerChris Lattner <sabre@nondot.org>2009-06-30 06:24:05 +0000
commit149f1386c60aa07de0f6a5d43ab524b22af68059 (patch)
tree7175c6b32d61afbbe32740691f5513ee9dd72dd3 /test/Sema/compare.c
parent17945a0f64fe03ff6ec0c2146005a87636e3ac12 (diff)
downloadclang-149f1386c60aa07de0f6a5d43ab524b22af68059.tar.gz
Implement PR4175, catching some questionable comparisons. Patch by
David Majnemer! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74513 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/compare.c')
-rw-r--r--test/Sema/compare.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index 4b44bf5b96..51f7731738 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -15,3 +15,17 @@ int arrays(char (*a)[5], char(*b)[10], char(*c)[5]) {
int d = (a == c);
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}}
+ return a > (void *)0; // expected-warning {{comparison of distinct pointer types}}
+}
+
+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}}
+}