3 /*@only@*/ int *globonly;
4 /*@shared@*/ int *globshared1;
5 /*@shared@*/ int *globshared2;
8 void f(/*@only@*/ int *x, /*@temp@*/ int *y, /*@shared@*/ int *z)
12 return; /* 1. bad x not released */
13 } /* 2. bad x not released */
15 int f2(/*@temp@*/ int *x, /*@only@*/ int *y)
19 return 3; /* 3. bad y not released */
22 void f3(/*@only@*/ int *x)
24 globshared1 = x; /* 4. bad shared globshared1 <- only x */
25 } /* 5. only not released */
27 void f4(/*@only@*/ int *x)
29 zonly = x; /* 6. bad - didn't release zonly */
35 int *y = malloc(sizeof(int));
36 int *y2 = malloc(sizeof(int));
37 int *y3 = malloc(sizeof(int));
41 f3 (imp); /* 7. bad if +memimplicit --- unqualified as only */
42 *imp = 5; /* 8. uses released */
44 (void) f(&x, /* 9, 10. pass immediate as only, only parameter aliased */
48 (void) f2 (y3, y3); /* 11-15. --- 2 * null passed as nonnull, 2 * not completely def
49 only parameter y3 aliased */
50 *y3 = 6; /* 16, 17. bad --- y3 was released, null */
51 (void) f(y, globshared1, globshared1); /* 18, 19. null as non-null, y not completely def */
52 (void) f(globshared1, /* 20. pass shared as only */
56 free (globshared2); /* 21. bad --- free's shared! (pass shared as only) */
59 return *y; /* 22-25. y used after release, possible null,
60 locally allocated y2 not released,
61 globonly is released */