summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/nonnull1.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/warn/nonnull1.C')
-rw-r--r--gcc/testsuite/g++.dg/warn/nonnull1.C16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/nonnull1.C b/gcc/testsuite/g++.dg/warn/nonnull1.C
new file mode 100644
index 000000000..46de7e931
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/nonnull1.C
@@ -0,0 +1,16 @@
+// Test that "nonnull" attribute works for C++.
+// Origin: Joseph Myers <jsm@polyomino.org.uk>
+// { dg-do compile }
+// { dg-options "-Wall" }
+
+// The "nonnull" attribute is thoroughly tested for C, so here we
+// simply test that it works at all, as at one point the relevant
+// checking code was only called for C.
+
+extern void f (char *) __attribute__((nonnull));
+
+void
+g ()
+{
+ f (0); // { dg-warning "null" "null argument" }
+}