]> andersk Git - splint.git/blob - test/alias.c
Remove unused cpplib_createDefinition.
[splint.git] / test / alias.c
1 # include "mut.h"
2
3 int glob;
4 int *globp;
5
6 int f(int *a, int b, int **c)
7 {
8   int *x, *y, *z;
9
10   x = a;   
11   *x = 3;  /* 1. modifies *a */
12   x = a;
13   y = x;
14   *y = 4;  /* 2. modifies *a */
15
16   globp = a;  /* 3. modifies *globp */
17   if (*x == 3) return 3; /* 4. returns aliasing globp */
18
19   if (*x == 4) 
20     {
21       globp = z; /* 5, 6. z use before def, modifies globp */
22       return 4; /* okay */
23     }
24   
25   *globp = 4; /* 7, 8. modifies *a, *globp */
26
27   x = globp;
28   *x = 7;     /* 9, 10. modifies *globp, *a */
29
30   x = &glob;
31   *x = 4;    /* 11. modifies glob */
32
33   x = &b;  /* okay */
34   *x = 3;  /* okay */
35   b = 3;   /* okay */
36   *x = b;  /* okay */
37   x = *c;  /* okay */
38   *x = 4;  /* 12. modifies **c */
39   a = *c;  /* okay */
40   *a = 4;  /* 13. modifies **c (but not *a) */
41   *globp = 3; /* 14, 15. modifies *globp, modifies *a */
42   return 4;   /* 16. returns with globp aliasing a */
43 }
44
45 int h (mut a, mut b) 
46
47   mut c = mut_create();
48
49   mut_mod (a);  /* 17. modifies a */
50   a = b;
51   mut_mod (a);  /* 18. modifies b */
52   b = c; 
53   mut_mod (b);  /* okay */
54
55   return 3;     /* 19. locally allocated storage c not released */
56 }
57
58
This page took 0.209772 seconds and 5 git commands to generate.