1 #include "analyzer-decls.h"
2
3 struct foo
4 {
5 int ival;
6 int iarr[10];
7 };
8
9 void test_1 (int i, int j)
10 {
11 struct foo fooarr[4];
12 fooarr[1].ival = 42;
13 fooarr[1].iarr[3] = 27;
14 fooarr[2].iarr[1] = 17;
15 __analyzer_eval (fooarr[1].ival == 42); /* { dg-warning "TRUE" } */
16 __analyzer_eval (fooarr[1].iarr[3] == 27); /* { dg-warning "TRUE" } */
17 __analyzer_eval (fooarr[2].iarr[1] == 17); /* { dg-warning "TRUE" } */
18
19 /* Symbolic binding. */
20 fooarr[2].iarr[i] = j;
21 __analyzer_eval (fooarr[2].iarr[i] == j); /* { dg-warning "TRUE" } */
22
23 /* We should have lost our knowledge about fooarr[2].
24 It's not clear to me if we should also lose our knowledge about
25 fooarr[1] (for the case where i is negative). For now, we do. */
26 __analyzer_eval (fooarr[1].ival == 42); /* { dg-warning "UNKNOWN" } */
27 __analyzer_eval (fooarr[1].iarr[3] == 27); /* { dg-warning "UNKNOWN" } */
28 __analyzer_eval (fooarr[2].iarr[1] == 17); /* { dg-warning "UNKNOWN" } */
29 /* Should also be safe to read from fooarr[2];
30 it isn't known to be uninit anymore. */
31 __analyzer_eval (fooarr[2].iarr[10] == 17); /* { dg-warning "UNKNOWN" } */
32 }