summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/nullptr22.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/nullptr22.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr22.C20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr22.C b/gcc/testsuite/g++.dg/cpp0x/nullptr22.C
new file mode 100644
index 000000000..d800f9869
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr22.C
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x -Wall -Wformat=2 -Wstrict-null-sentinel" }
+
+// Test various warnings
+
+void f1(const char*, ...) __attribute__((format(printf, 1, 2)));
+void f2(const char*) __attribute__((nonnull));
+void f3(const char*, ...) __attribute__((sentinel));
+
+void f()
+{
+ f1("%p", nullptr);
+ f2(nullptr); // { dg-warning "null argument where non-null required " }
+ f3("x", "y", __null); // { dg-warning "missing sentinel in function call" }
+ f3("x", "y", nullptr);
+ decltype(nullptr) mynull = 0;
+ f1("%p", mynull);
+ f2(mynull); // { dg-warning "null argument where non-null required " }
+ f3("x", "y", mynull);
+}