1 struct foo { 2 int a; 3 }; 4 5 struct foo *a; 6 struct foo *b; 7 struct foo *c; 8 struct foo *d; 9 int x, y, z; 10 11 void func (void) 12 { 13 a = 0; 14 b = 0; 15 c = 0; 16 d = 0; 17 18 if (x) 19 a = returns_nonnull(); 20 else 21 b = returns_nonnull(); 22 if (y) 23 a = returns_nonnull(); 24 else 25 c = returns_nonnull(); 26 __smatch_extra_values(); 27 if (x || y) { 28 a->a = 1; 29 b->a = 2; 30 }else { 31 c->a = 3; 32 } 33 } 34 /* 35 * check-name: Smatch implied #6 36 * check-command: smatch --spammy sm_implied6.c 37 * 38 * check-output-start 39 sm_implied6.c:29 func() error: potential NULL dereference 'b'. 40 * check-output-end 41 */ 42