diff options
author | Jason Thorpe <thorpej@wasabisystems.com> | 2002-05-23 18:32:12 +0000 |
---|---|---|
committer | Jason Thorpe <thorpej@gcc.gnu.org> | 2002-05-23 18:32:12 +0000 |
commit | 79ed7328ef779277dfd4bca0ab254db30416e6b7 (patch) | |
tree | a0f4ef4e49cca963a0f7c4212cd7cef8b803fee1 /gcc/testsuite/gcc.dg/format/null-1.c | |
parent | 7d600178a1a29a16894173ce60ebf3599c571ea5 (diff) | |
download | gcc-79ed7328ef779277dfd4bca0ab254db30416e6b7.zip gcc-79ed7328ef779277dfd4bca0ab254db30416e6b7.tar.gz gcc-79ed7328ef779277dfd4bca0ab254db30416e6b7.tar.bz2 |
builtin-attrs.def: Update copyright years.
* builtin-attrs.def: Update copyright years.
(ATTR_NONNULL): New attribute identifier.
(ATTR_NONNULL_1, ATTR_NONNULL_2, ATTR_NONNULL_3): New
attribute tree lists.
(DEF_FORMAT_ATTRIBUTE): Chain a nonnull attribute for the
format operand.
(ATTR_FORMAT_ARG_1, ATTR_FORMAT_ARG_2): Use...
(DEF_FORMAT_ARG_ATTRIBUTE): ...this to generate format_arg
attribute lists. Chain the appropriate nonnull attribute.
* c-format.c (check_format_arg): Remove null format string
warning.
* testsuite/gcc.dg/format/null-1.c: New test.
From-SVN: r53801
Diffstat (limited to 'gcc/testsuite/gcc.dg/format/null-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/format/null-1.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/format/null-1.c b/gcc/testsuite/gcc.dg/format/null-1.c new file mode 100644 index 0000000..63501a39 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/null-1.c @@ -0,0 +1,27 @@ +/* Test for some aspects of null format string handling. */ +/* Origin: Jason Thorpe <thorpej@wasabisystems.com> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wformat" } */ + +#include "format.h" + +extern void my_printf (const char *, ...) __attribute__((format(printf,1,2))); +extern const char *my_format (const char *, const char *) + __attribute__((format_arg(2))); + +void +foo (int i1) +{ + /* Warning about a null format string has been decoupled from the actual + format check. However, we still expect to be warned about any excess + arguments after a null format string. */ + my_printf (NULL); + my_printf (NULL, i1); /* { dg-warning "too many" "null format with arguments" } */ + + my_printf (my_format ("", NULL)); + my_printf (my_format ("", NULL), i1); /* { dg-warning "too many" "null format_arg with arguments" } */ + + /* While my_printf allows a null argument, dgettext does not, so we expect + a null argument warning here. */ + my_printf (dgettext ("", NULL)); /* { dg-warning "null" "null format with dgettext" } */ +} |