Update concepts branch to revision 131834
[official-gcc.git] / gcc / testsuite / gcc.dg / format / ms_c90-printf-3.c
blob8e4b19a774e482f114421eef995620e21ee8e0d4
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
3 do not.
4 */
5 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
6 /* { dg-do compile { target { *-*-mingw* } } } */
7 /* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
9 #define USE_SYSTEM_FORMATS
10 #include "format.h"
12 void
13 foo (int i, char *s, size_t n, va_list v0, va_list v1, va_list v2, va_list v3,
14 va_list v4, va_list v5, va_list v6, va_list v7, va_list v8)
16 fprintf (stdout, "%d", i);
17 fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */
18 printf ("%d", i);
19 printf ("%ld", i); /* { dg-warning "format" "printf" } */
20 /* The "unlocked" functions shouldn't warn in c90 mode. */
21 fprintf_unlocked (stdout, "%ld", i);
22 printf_unlocked ("%ld", i);
23 sprintf (s, "%d", i);
24 sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */
25 vfprintf (stdout, "%d", v0);
26 vfprintf (stdout, "%Y", v1); /* { dg-warning "format" "vfprintf" } */
27 vprintf ("%d", v2);
28 vprintf ("%Y", v3); /* { dg-warning "format" "vprintf" } */
29 /* The following used to give a bogus warning. */
30 vprintf ("%*.*d", v8); /* { dg-bogus "format" "vprintf" } */
31 vsprintf (s, "%d", v4);
32 vsprintf (s, "%Y", v5); /* { dg-warning "format" "Y is invalid" } */
33 snprintf (s, n, "%d", i);
34 snprintf (s, n, "%ld", i);
35 vsnprintf (s, n, "%d", v6);
36 vsnprintf (s, n, "%Y", v7);
37 printf (gettext ("%d"), i);
38 printf (gettext ("%ld"), i);
39 printf (dgettext ("", "%d"), i);
40 printf (dgettext ("", "%ld"), i);
41 printf (dcgettext ("", "%d", 0), i);
42 printf (dcgettext ("", "%ld", 0), i);