]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | int x1, x2, x3; |
2 | ||
3 | int g() | |
4 | { | |
5 | return x1 + x2 + x3; /* 1. uses x3 before definition */ | |
6 | } | |
7 | ||
8 | int f() | |
9 | { | |
10 | int loc; | |
11 | ||
12 | if (3 > 4) | |
13 | { | |
14 | loc = 3; | |
15 | return x1; /* 2, 3, 4. bad --- x1 not defined, x2, x3 not defined */ | |
16 | } | |
17 | else | |
18 | { | |
19 | if (4 > 6) | |
20 | { | |
21 | loc = x1; /* 5. x1 not defined */ | |
22 | loc = g(); /* 6. bad --- x1, x2 not defined before call (defines x2 and x3) */ | |
23 | loc = x3; | |
24 | } | |
25 | else if (2 > 3) | |
26 | { | |
27 | loc = x3; /* 7. x3 not defined */ | |
28 | x1 = 6; | |
29 | x2 = 7; | |
30 | return g(); | |
31 | } | |
32 | else | |
33 | { | |
34 | x1 = 6; | |
35 | x2 = 7; | |
36 | ||
37 | return 12; /* 8. returns with x3 not defined */ | |
38 | } | |
39 | } | |
40 | ||
80ee600a | 41 | return 12; |
42 | /* No errors to report. Previously, | |
43 | [9, 10. returns with x2 and x3 undefined (x1 IS defined on all branches!)] | |
44 | but this is not correct; all branches that can reach the return do define | |
45 | x1, x2 and x3. | |
46 | */ | |
885824d3 | 47 | } |
48 | ||
49 | int h (void) | |
50 | { | |
51 | return x1; /* okay */ | |
52 | } | |
53 | ||
54 | ||
55 | ||
56 | ||
57 | ||
58 | ||
59 |