OSDN Git Service

* gcc.dg/altivec-vec-merge.c: Make test usable on GNU/Linux targets
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / format / null-1.c
1 /* Test for some aspects of null format string handling.  */
2 /* Origin: Jason Thorpe <thorpej@wasabisystems.com> */
3 /* { dg-do compile } */
4 /* { dg-options "-std=gnu99 -Wformat" } */
5
6 #include "format.h"
7
8 extern void my_printf (const char *, ...) __attribute__((format(printf,1,2)));
9 extern const char *my_format (const char *, const char *)
10   __attribute__((format_arg(2)));
11
12 void
13 foo (int i1)
14 {
15   /* Warning about a null format string has been decoupled from the actual
16      format check.  However, we still expect to be warned about any excess
17      arguments after a null format string.  */
18   my_printf (NULL);
19   my_printf (NULL, i1); /* { dg-warning "too many" "null format with arguments" } */
20
21   my_printf (my_format ("", NULL));
22   my_printf (my_format ("", NULL), i1); /* { dg-warning "too many" "null format_arg with arguments" } */
23
24   /* While my_printf allows a null argument, dgettext does not, so we expect
25      a null argument warning here.  */
26   my_printf (dgettext ("", NULL)); /* { dg-warning "null" "null format with dgettext" } */
27 }