diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/nonnull-2.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/nonnull-2.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/nonnull-2.c b/gcc/testsuite/gcc.dg/nonnull-2.c new file mode 100644 index 000000000..bd36d232d --- /dev/null +++ b/gcc/testsuite/gcc.dg/nonnull-2.c @@ -0,0 +1,16 @@ +/* Test for the invalid use of the "nonnull" function attribute. */ +/* Origin: Jason Thorpe <thorpej@wasabisystems.com> */ +/* { dg-do compile } */ + +extern void func1 () __attribute__((nonnull)); /* { dg-error "without arguments" } */ + +extern void func2 (char *) __attribute__((nonnull(2))); /* { dg-error "out-of-range operand" } */ + +extern void func3 (char *) __attribute__((nonnull(foo))); /* { dg-error "invalid operand number" } */ + +extern void func4 (int) __attribute__((nonnull(1))); /* { dg-error "references non-pointer" } */ + +void +foo (void) +{ +} |