Some consistency changes to library & headers flags.
[splint-patched.git] / test / special.c
blob1e4d6cb2de73d11e7e52d8a0e7b30612bf22ef20
1 char gc;
2 int gi;
3 char *gs;
5 int f()
7 signed char c;
8 unsigned char uc;
9 int i;
10 long int li = 23;
11 short int silly = 3;
12 char *s;
14 printf("hullo this is a %s !", "test");
15 (void) scanf("hullo, welcome to %d", &i); /* defines i */
17 printf("even %d %c harder", i, c); /* 1. Variable c used before definition */
18 uc = 'a';
19 printf("even %d %c harder", li, uc); /* 2. printf format arg 1 (%d) expects int gets long int: li */
20 printf("even %ld %d %hd %hd %d harder", i, li, i, silly, silly); /* 3, 4. [5, 6.]
21 * arg1 (expects long),
22 arg2 (expects int),
23 arg3 (expects short),
24 * (okay if +relaxquals) arg5 (expects int) */
26 (void) scanf("%*d okay"); /* [NO! 5. Statement has no effect] */
27 printf("%s %s", s, s); /* 5. Variable s used before definition */
29 printf("a real %+14.3i", c, i); /* 6, 7. printf format arg 1 (%i) expects int gets char: c, extra arg */
30 fprintf(stdout, "a real %+14.33i", c, i); /* 8, 9. fprintf format arg 1 (%i) expects int gets char: c, extra */
31 printf("%% %d %f %f", c, i); /* 10, 11, 12. printf format arg 1, arg2, missing arg 3 */
33 (void) scanf("hullo, welcome to %d", &i);
34 (void) scanf("hullo, welcome to %d", i); /* 13. scanf format arg 1 (%d) expects int * gets int: i */
36 /* 3 type errors */
37 (void) fscanf(stdin, "hullo, welcome to %d %c %s", i, c, &s); /* 14, 15, 16. arg1, arg2, arg3 */
39 (void) scanf("hullo, welcome to %hhd", &c);
40 fprintf(stdin, "hullo, welcome to %hhu\n", c); /* 17. */
42 (void) fscanf(stdout, "hullo, welcome to %hho", &c); /* 18. */
43 printf("hullo, welcome to %hhi\n", c);
45 /* 3 modification errors */
46 (void) fscanf(stdin, "hullo, welcome to %23d %c %s", &gi, &gc, gs); /* 19, 20, 21. modifies g1, gc, gs */
47 /* 1 modification error */
48 (void) fscanf(stdin, "hullo, welcome to %*23d %*c %s", gs); /* 22. modifies gs */
50 return 3;