1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <libc-diag.h>
4
5 int
main(int arc,char * argv[])6 main(int arc, char *argv[])
7 {
8 int res;
9 unsigned int val;
10
11 FILE *fp = fopen ("/dev/null", "r");
12
13 val = 0;
14 res = fscanf(fp, "%n", &val);
15
16 printf("Result of fscanf %%n = %d\n", res);
17 printf("Scanned format = %d\n", val);
18
19 /* We're testing exactly the case the warning is for. */
20 DIAG_PUSH_NEEDS_COMMENT;
21 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-zero-length");
22
23 res = fscanf(fp, "");
24
25 DIAG_POP_NEEDS_COMMENT;
26
27 printf("Result of fscanf \"\" = %d\n", res);
28 if (res != 0)
29 abort ();
30
31 res = fscanf(fp, "BLURB");
32 printf("Result of fscanf \"BLURB\" = %d\n", res);
33 if (res >= 0)
34 abort ();
35
36 fclose (fp);
37
38 return 0;
39 return 0;
40 }
41