diff options
| author | thorpej <thorpej@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-23 15:48:05 +0000 |
|---|---|---|
| committer | thorpej <thorpej@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-23 15:48:05 +0000 |
| commit | dbf6c367801e1bf1d0cec09a2fe8fef7f7957c3f (patch) | |
| tree | ec1ff9d3e5c1ac88998d2453691cca3c42bc0416 /gcc/testsuite/gcc.dg/nonnull-2.c | |
| parent | 43a852ea4edb3bace60c8f0880cdc1768ace6151 (diff) | |
| download | ppe42-gcc-dbf6c367801e1bf1d0cec09a2fe8fef7f7957c3f.tar.gz ppe42-gcc-dbf6c367801e1bf1d0cec09a2fe8fef7f7957c3f.zip | |
* c-common.c (warn_nonnull): Declare.
(c_common_attribute_table): Add "nonnull" attribute.
(handle_nonnull_attribute, check_function_nonnull, nonnull_check_p,
check_nonnull_arg, get_nonnull_operand, check_function_arguments,
check_function_arguments_recurse): New functions.
* c-common.h (warn_nonnull): Declare extern.
(check_function_arguments, check_function_arguments_recurse): New
prototypes.
* c-decl.c (c_decode_option): Add -Wnonnull option.
* c-format.c (set_Wformat): Set warn_nonnull if enabling
format checking.
(format_check_context): New structure.
(check_format_info_recurse): Remove recursion and rename to...
(check_format_arg): ...this. Update comment.
(check_format_info): Use check_function_arguments_recurse.
* c-typeck.c (build_function_call): Call check_function_arguments
instead of check_function_format.
* doc/extend.texi: Document "nonnull" attribute.
* doc/invoke.texi: Docuemnt -Wnonnull option.
* testsuite/gcc.dg/nonnull-1.c: New test.
* testsuite/gcc.dg/nonnull-2.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53790 138bc75d-0d04-0410-961f-82ee72b054a4
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 00000000000..bd36d232d38 --- /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) +{ +} |

