1 /* Test for format extensions.  Test that the C99 functions get their
2    default attributes in gnu89 mode.
3 */
4 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
5 /* { dg-do compile } */
6 /* { dg-options "-std=gnu89 -Wformat" } */
7 
8 #include "format.h"
9 
10 void
foo(int i,char * s,size_t n,int * ip,va_list v0,va_list v1,va_list v2,va_list v3,va_list v4,va_list v5,va_list v6,va_list v7,va_list v8,va_list v9,va_list v10,va_list v11,va_list v12,va_list v13)11 foo (int i, char *s, size_t n, int *ip, va_list v0, va_list v1, va_list v2,
12      va_list v3, va_list v4, va_list v5, va_list v6, va_list v7, va_list v8,
13      va_list v9, va_list v10, va_list v11, va_list v12, va_list v13)
14 {
15   fprintf (stdout, "%d", i);
16   fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */
17   printf ("%d", i);
18   printf ("%ld", i); /* { dg-warning "format" "printf" } */
19   fprintf_unlocked (stdout, "%d", i);
20   fprintf_unlocked (stdout, "%ld", i); /* { dg-warning "format" "fprintf_unlocked" } */
21   printf_unlocked ("%d", i);
22   printf_unlocked ("%ld", i); /* { dg-warning "format" "printf_unlocked" } */
23   sprintf (s, "%d", i);
24   sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */
25   snprintf (s, n, "%d", i);
26   snprintf (s, n, "%ld", i); /* { dg-warning "format" "snprintf" } */
27   vfprintf (stdout, "%d", v0);
28   vfprintf (stdout, "%Y", v1); /* { dg-warning "format" "vfprintf" } */
29   vprintf ("%d", v2);
30   vprintf ("%Y", v3); /* { dg-warning "format" "vprintf" } */
31   vsprintf (s, "%d", v4);
32   vsprintf (s, "%Y", v5); /* { dg-warning "format" "vsprintf" } */
33   vsnprintf (s, n, "%d", v6);
34   vsnprintf (s, n, "%Y", v7); /* { dg-warning "format" "vsnprintf" } */
35   fscanf (stdin, "%d", ip);
36   fscanf (stdin, "%ld", ip); /* { dg-warning "format" "fscanf" } */
37   scanf ("%d", ip);
38   scanf ("%ld", ip); /* { dg-warning "format" "scanf" } */
39   sscanf (s, "%d", ip);
40   sscanf (s, "%ld", ip); /* { dg-warning "format" "sscanf" } */
41   vfscanf (stdin, "%d", v8);
42   vfscanf (stdin, "%Y", v9); /* { dg-warning "format" "vfscanf" } */
43   vscanf ("%d", v10);
44   vscanf ("%Y", v11); /* { dg-warning "format" "vscanf" } */
45   vsscanf (s, "%d", v12);
46   vsscanf (s, "%Y", v13); /* { dg-warning "format" "vsscanf" } */
47 }
48