implied_value: don't get confused by casts
[smatch.git] / validation / sm_switch2.c
blob953e270228c0f3144e57a75a16b94ad8e4c14a7d
1 struct foo {
2 int a;
3 };
5 struct foo *a;
6 struct foo *b;
7 struct foo *c;
8 struct foo *d;
9 int x;
11 void func (void)
13 a = 0;
14 b = 0;
15 c = 0;
16 d = 0;
18 if (x == 1)
19 a = some_func();
20 else if (x == 2)
21 b = some_func();
22 else if (x == 3)
23 c = some_func();
24 else
25 d = some_func();
27 switch(x) {
28 case 1:
29 a->a = 1;
30 case 2:
31 a->a = 2;
32 b->a = 3;
33 break;
34 case 3:
35 c->a = 4;
36 break;
37 case 4:
38 d->a = 5;
39 break;
43 * check-name: Smatch switch handling #2
44 * check-command: smatch sm_switch2.c
46 * check-output-start
47 sm_switch2.c:31 func() error: potential NULL dereference 'a'.
48 sm_switch2.c:32 func() error: potential NULL dereference 'b'.
49 * check-output-end