summaryrefslogtreecommitdiffstats
path: root/test/Sema/warn-null.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema/warn-null.c')
-rw-r--r--test/Sema/warn-null.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/Sema/warn-null.c b/test/Sema/warn-null.c
new file mode 100644
index 0000000..28fb6a5
--- /dev/null
+++ b/test/Sema/warn-null.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -verify
+
+// PR10837: Warn if a non-pointer-typed expression is folded to a null pointer
+int *p = 0;
+int *q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
+int *r = (1 - 1); // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
+void f() {
+ p = 0;
+ q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
+ r = 1 - 1; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
+}
OpenPOWER on IntegriCloud