*new* check_macros: find macro precedence bugs
[smatch.git] / validation / sm_select.c
blob074b162cf18e0d1ba83e9ca58075a22f57450e64
1 struct foo {
2 int a;
3 };
5 struct foo *a;
6 struct foo *b;
8 struct foo *c;
9 struct foo *d;
10 struct foo *e;
11 void func (void)
13 if (a?b:0) {
14 a->a = 1;
15 b->a = 1;
17 a->a = 1;
18 b->a = 1;
19 e->a = 1;
20 d = returns_nonnull();
21 if (c?d:e) {
22 c->a = 1;
23 d->a = 1;
24 e->a = 1;
26 e->a = 1;
30 * check-name: Ternary Conditions
31 * check-command: smatch sm_select.c
33 * check-output-start
34 sm_select.c +17 func(6) error: we previously assumed 'a' could be null.
35 sm_select.c +18 func(7) error: we previously assumed 'b' could be null.
36 sm_select.c +21 func(10) warn: variable dereferenced before check 'e'
37 sm_select.c +22 func(11) error: we previously assumed 'c' could be null.
38 sm_select.c +26 func(15) error: we previously assumed 'e' could be null.
39 * check-output-end