summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Headers/needsnull.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/Headers/needsnull.cpp b/clang/test/Headers/needsnull.cpp
new file mode 100644
index 00000000000..267cb5ddc31
--- /dev/null
+++ b/clang/test/Headers/needsnull.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -triple i386-linux-gnu -verify -Wsentinel %s
+// expected-no-diagnostics
+
+#include <stddef.h>
+
+// linux/stddef.h does something like this for cpp files:
+#undef NULL
+#define NULL 0
+
+// glibc (and other) headers then define __need_NULL and rely on stddef.h
+// to redefine NULL to the correct value again.
+#define __need_NULL
+#include <stddef.h>
+
+// gtk headers then use __attribute__((sentinel)), which doesn't work if NULL
+// is 0.
+void f(const char* c, ...) __attribute__((sentinel));
+void g() {
+ f("", NULL); // Shouldn't warn.
+}
OpenPOWER on IntegriCloud