]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | # include "bool.h" |
2 | ||
3 | typedef /*@null@*/ int *mnull; | |
4 | ||
5 | extern /*@notnull@*/ mnull mnull_create (void); | |
6 | ||
7 | extern int f1 (/*@notnull@*/ mnull x); /* 1. Function f1 declared with notnull ... */ | |
8 | ||
9 | int f (mnull x) | |
10 | { | |
11 | return *x; /* 2. Possible dereference of null pointer: *x */ | |
12 | } | |
13 | ||
14 | static /*@unused@*/ int f2 (/*@notnull@*/ mnull x) | |
15 | { | |
16 | return *x; | |
17 | } | |
18 | ||
19 | extern /*@falsenull@*/ bool isThree (mnull x); | |
20 | ||
21 | static /*@unused@*/ int f3 (/*@notnull@*/ mnull x) | |
22 | { | |
23 | if (isThree (x)) /* the parameter was missing before 2.4! */ | |
24 | { | |
25 | *x = 4; | |
26 | } | |
27 | else | |
28 | { | |
29 | *x = 5; | |
30 | } | |
31 | ||
32 | return (*x); | |
33 | } | |
34 | ||
35 | /*@notnull@*/ mnull f4 (void) | |
36 | { | |
37 | mnull x = NULL; | |
38 | ||
39 | if (x == NULL) | |
40 | { | |
41 | x = mnull_create (); | |
42 | } | |
43 | ||
44 | return x; | |
45 | } | |
46 | ||
47 | /*@notnull@*/ mnull f5 (void) | |
48 | { | |
49 | static /*@only@*/ mnull x = NULL; | |
50 | ||
51 | if (x == NULL) | |
52 | { | |
53 | x = mnull_create (); | |
54 | } | |
55 | ||
56 | return x; | |
57 | } | |
58 | ||
59 | /*@notnull@*/ mnull f6 (void) | |
60 | { | |
61 | static /*@only@*/ mnull x = NULL; | |
62 | ||
63 | if (x != NULL) | |
64 | { | |
65 | x = mnull_create (); | |
66 | } | |
67 | ||
68 | return x; /* 3. Possibly null storage returned as non-null */ | |
69 | } | |
70 | ||
71 | /*@notnull@*/ mnull f7 (void) | |
72 | { | |
73 | static /*@only@*/ mnull x = NULL; | |
74 | ||
75 | if (x == NULL) | |
76 | { | |
77 | x = mnull_create (); | |
78 | } | |
79 | else | |
80 | { | |
81 | x = NULL; | |
82 | } | |
83 | ||
84 | return x; /* 4. Possibly null storage returned as non-null */ | |
85 | } |