Don't try calling lsl when file is missing.
[splint-patched.git] / test / fields.c
blob9f2c94eb478a24c5e9df530f6d2e312a03ae4b6a
1 typedef struct
3 /*@owned@*/ int *x;
4 /*@owned@*/ int *y;
5 /*@dependent@*/ int *z;
6 } *pair;
8 extern /*@only@*/ /*@out@*/ void *smalloc (size_t);
10 /*@only@*/ pair pair_create (void)
12 pair p = (pair) smalloc (sizeof (*p));
14 p->x = smalloc (sizeof (int));
15 p->y = smalloc (sizeof (int));
16 p->z = p->y;
18 *(p->x) = 3;
19 *(p->y) = 12;
21 return p;
24 /*@only@*/ pair pair_create1 (void)
26 pair p = (pair) smalloc (sizeof (*p));
28 p->x = smalloc (sizeof (int));
29 p->y = smalloc (sizeof (int));
30 p->z = p->y;
31 *(p->y) = 12;
33 *(p->x) = 3;
34 p->y = smalloc (sizeof (int));
35 *(p->y) = 12;
37 return p; /* 1. Returned storage p->z is only (should be dependant): p */
40 void mangle (/*@temp@*/ pair p)
42 free (p->x);
43 } /* 2. Released storage p->x reachable from parameter */
45 void mangle2 (/*@temp@*/ pair p)
47 free (p->x);
48 p->x = p->y;
49 } /* 3. Storage p->y reachable from parameter is dependant */
51 /*@only@*/ pair mangle3 (/*@only@*/ pair p)
53 free (p->x);
54 p->x = p->y;
55 return p; /* 4. Storage p->y reachable from return value is dependant (should be */
58 int f (pair p)
60 p->x = NULL; /* 5. Only storage p->x not released before assignment: p->x = NULL */
62 return *(p->y);
65 void swap (pair p)
67 int *tmp = p->x;
69 p->x = p->y;
70 p->y = tmp;
73 void mangleok (/*@temp@*/ pair p)
75 int *loc = p->x;
76 *loc = 8;