1 /* Test for printf formats. Test that the C99 functions get their default
2 attributes in strict C99 mode, but the gettext functions do not.
4 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
5 /* { dg-do compile { target { ! *-*-mingw* } } } */
6 /* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
11 foo (int i
, char *s
, size_t n
, va_list v0
, va_list v1
, va_list v2
, va_list v3
,
12 va_list v4
, va_list v5
, va_list v6
, va_list v7
)
14 fprintf (stdout
, "%d", i
);
15 fprintf (stdout
, "%ld", i
); /* { dg-warning "format" "fprintf" } */
17 printf ("%ld", i
); /* { dg-warning "format" "printf" } */
18 /* The "unlocked" functions shouldn't warn in c99 mode. */
19 fprintf_unlocked (stdout
, "%ld", i
); /* { dg-bogus "format" "fprintf_unlocked" } */
20 printf_unlocked ("%ld", i
); /* { dg-bogus "format" "printf_unlocked" } */
22 sprintf (s
, "%ld", i
); /* { dg-warning "format" "sprintf" } */
23 snprintf (s
, n
, "%d", i
);
24 snprintf (s
, n
, "%ld", i
); /* { dg-warning "format" "snprintf" } */
25 vfprintf (stdout
, "%d", v0
);
26 vfprintf (stdout
, "%Y", v1
); /* { dg-warning "format" "vfprintf" } */
28 vprintf ("%Y", v1
); /* { dg-warning "format" "vprintf" } */
29 vsprintf (s
, "%d", v0
);
30 vsprintf (s
, "%Y", v1
); /* { dg-warning "format" "vsprintf" } */
31 vsnprintf (s
, n
, "%d", v0
);
32 vsnprintf (s
, n
, "%Y", v1
); /* { dg-warning "format" "vsnprintf" } */
33 printf (gettext ("%d"), i
);
34 printf (gettext ("%ld"), i
);
35 printf (dgettext ("", "%d"), i
);
36 printf (dgettext ("", "%ld"), i
);
37 printf (dcgettext ("", "%d", 0), i
);
38 printf (dcgettext ("", "%ld", 0), i
);