]> andersk Git - splint.git/blame - test/special.c
noexpand always false.
[splint.git] / test / special.c
CommitLineData
885824d3 1char gc;
2int gi;
3char *gs;
4
5int f()
6{
7 char c;
8 unsigned char uc;
9 int i;
10 long int li = 23;
11 short int silly = 3;
12 char *s;
13
14 printf("hullo this is a %s !", "test");
15 (void) scanf("hullo, welcome to %d", &i); /* defines i */
16
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) */
25
26 (void) scanf("%*d okay"); /* [NO! 5. Statement has no effect] */
27 printf("%s %s", s, s); /* 5. Variable s used before definition */
28
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 */
32
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 */
35
36 /* 3 type errors */
37 (void) fscanf(stdin, "hullo, welcome to %d %c %s", i, c, &s); /* 14, 15, 16. arg1, arg2, arg3 */
38
39 /* 3 modification errors */
40 (void) fscanf(stdin, "hullo, welcome to %23d %c %s", &gi, &gc, gs); /* 17, 18, 19. modifies g1, gc, gs */
41 /* 1 modification error */
42 (void) fscanf(stdin, "hullo, welcome to %*23d %*c %s", gs); /* 20. modifies gs */
43
44 return 3;
45}
46
47
This page took 0.472006 seconds and 5 git commands to generate.