aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/format
diff options
context:
space:
mode:
authorJason Thorpe <thorpej@wasabisystems.com>2002-05-23 18:32:12 +0000
committerJason Thorpe <thorpej@gcc.gnu.org>2002-05-23 18:32:12 +0000
commit79ed7328ef779277dfd4bca0ab254db30416e6b7 (patch)
treea0f4ef4e49cca963a0f7c4212cd7cef8b803fee1 /gcc/testsuite/gcc.dg/format
parent7d600178a1a29a16894173ce60ebf3599c571ea5 (diff)
downloadgcc-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')
-rw-r--r--gcc/testsuite/gcc.dg/format/null-1.c27
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" } */
+}