1 /* Test for scanf 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 } */
6 /* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
8 /* This may not be correct in the particular case, but allows the
9 prototypes to be declared, and we don't try to link.
11 typedef struct _FILE FILE;
14 typedef __builtin_va_list va_list;
16 extern int fscanf (FILE *restrict, const char *restrict, ...);
17 extern int scanf (const char *restrict, ...);
18 extern int sscanf (const char *restrict, const char *restrict, ...);
19 extern int vfscanf (FILE *restrict, const char *restrict, va_list);
20 extern int vscanf (const char *restrict, va_list);
21 extern int vsscanf (const char *restrict, const char *restrict, va_list);
23 extern char *gettext (const char *);
24 extern char *dgettext (const char *, const char *);
25 extern char *dcgettext (const char *, const char *, int);
28 foo (int *ip, char *s, va_list v0, va_list v1, va_list v2, va_list v3,
29 va_list v4, va_list v5)
31 fscanf (stdin, "%d", ip);
32 fscanf (stdin, "%ld", ip); /* { dg-warning "format" "fscanf" } */
34 scanf ("%ld", ip); /* { dg-warning "format" "scanf" } */
36 sscanf (s, "%ld", ip); /* { dg-warning "format" "sscanf" } */
37 vfscanf (stdin, "%d", v0);
38 vfscanf (stdin, "%Y", v1); /* { dg-warning "format" "vfscanf" } */
40 vscanf ("%Y", v3); /* { dg-warning "format" "vscanf" } */
41 vsscanf (s, "%d", v4);
42 vsscanf (s, "%Y", v5); /* { dg-warning "format" "vsscanf" } */
43 scanf (gettext ("%d"), ip);
44 scanf (gettext ("%ld"), ip);
45 scanf (dgettext ("", "%d"), ip);
46 scanf (dgettext ("", "%ld"), ip);
47 scanf (dcgettext ("", "%d", 0), ip);
48 scanf (dcgettext ("", "%ld", 0), ip);