1 /* Test for printf formats. Test that the C90 functions get their default
2 attributes in strict C90 mode, but the C99 and gettext functions
5 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
6 /* { dg-do compile } */
7 /* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
12 foo (int i
, char *s
, size_t n
, va_list v0
, va_list v1
, va_list v2
, va_list v3
,
13 va_list v4
, va_list v5
, va_list v6
, va_list v7
, va_list v8
)
15 fprintf (stdout
, "%d", i
);
16 fprintf (stdout
, "%ld", i
); /* { dg-warning "format" "fprintf" } */
18 printf ("%ld", i
); /* { dg-warning "format" "printf" } */
19 /* The "unlocked" functions shouldn't warn in c90 mode. */
20 fprintf_unlocked (stdout
, "%ld", i
); /* { dg-bogus "format" "fprintf_unlocked" } */
21 printf_unlocked ("%ld", i
); /* { dg-bogus "format" "printf_unlocked" } */
23 sprintf (s
, "%ld", i
); /* { dg-warning "format" "sprintf" } */
24 vfprintf (stdout
, "%d", v0
);
25 vfprintf (stdout
, "%Y", v1
); /* { dg-warning "format" "vfprintf" } */
27 vprintf ("%Y", v3
); /* { dg-warning "format" "vprintf" } */
28 /* The following used to give a bogus warning. */
29 vprintf ("%*.*d", v8
);
30 vsprintf (s
, "%d", v4
);
31 vsprintf (s
, "%Y", v5
); /* { dg-warning "format" "vsprintf" } */
32 snprintf (s
, n
, "%d", i
);
33 snprintf (s
, n
, "%ld", i
);
34 vsnprintf (s
, n
, "%d", v6
);
35 vsnprintf (s
, n
, "%Y", v7
);
36 printf (gettext ("%d"), i
);
37 printf (gettext ("%ld"), i
);
38 printf (dgettext ("", "%d"), i
);
39 printf (dgettext ("", "%ld"), i
);
40 printf (dcgettext ("", "%d", 0), i
);
41 printf (dcgettext ("", "%ld", 0), i
);