Some consistency changes to library & headers flags.
[splint-patched.git] / test / sharing4.c
blob0e2ed802e0ded04985482baeb2ef2d5f9b2dd65d
1 /*@only@*/ char *globonly1;
2 /*@only@*/ char *globonly2;
3 /*@only@*/ char *globonly3;
4 /*@only@*/ char *globonly4;
5 /*@only@*/ char *globonly5;
6 /*@shared@*/ char *globshared1;
7 /*@shared@*/ char *globshared2;
9 extern void free (/*@out@*/ /*@only@*/ void *s);
10 extern /*@only@*/ char *string_copy (char *s) /*@modifies nothing;@*/ ;
12 int f(/*@only@*/ char *only1, /*@only@*/ char *only2, /*@only@*/ char *only3,
13 char *temp1, /*@temp@*/ char *temp2,
14 /*@shared@*/ char *shared1, /*@shared@*/ char *shared2)
16 char *local1;
18 globonly1 = only1; /* 1. Only storage globonly1 not released before assignment */
19 free (globonly2);
20 globonly2 = only2;
21 free (globonly3); /* okay...for now */
23 globonly4 = shared1; /* 2. Only storage globonly4 not released before assignment
24 3. Shared storage assigned to only */
25 globshared1 = shared2;
26 globshared1 = globshared2;
27 globshared1 = globonly5; /* 4. Only storage assigned to shared */
29 local1 = globonly1;
30 globshared1 = local1; /* 5. Only storage globonly1 assigned to shared (local1 aliases */
31 /* 6. Kept storage only1 assigned to shared (local1 aliases */
32 globshared1 = string_copy (local1); /* 7. Only storage assigned to shared */
34 globshared2 = temp2; /* 8. Temp storage temp2 assigned to shared */
35 globonly4 = temp1; /* 9. Only storage globonly4 not released before assignment
36 10. Temp storage temp1 assigned to only: globonly4 = temp1 */
38 free (shared1); /* 11. Shared storage shared1 passed as only param */
39 *only3 = 'a';
40 *shared2 = 'c';
42 return 3; /* 12. Only storage only3 not released before return */
43 /* 13. Function returns with global globonly3 referencing released */