Add __builtion_unreachable to vector::size(), vector::capacity()
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / clobbers-1.c
blob6400f845f9eb3924991ef9734e620a287c1705b8
1 #include "analyzer-decls.h"
3 struct foo
5 int i;
6 int j;
7 };
9 struct coord
11 int x;
12 int y;
13 int z;
16 struct foo g;
18 void test_1 (void)
20 g.i = 42;
21 if (g.j)
22 __analyzer_eval (g.j); /* { dg-warning "TRUE" } */
23 else
24 __analyzer_eval (g.j); /* { dg-warning "FALSE" } */
25 __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
28 void test_2 (struct foo f)
30 f.i = 42;
31 if (f.j)
32 __analyzer_eval (f.j); /* { dg-warning "TRUE" } */
33 else
34 __analyzer_eval (f.j); /* { dg-warning "FALSE" } */
35 __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
38 void test_3 (struct foo *p)
40 struct foo f = *p;
41 f.i = 42;
42 if (f.j)
43 __analyzer_eval (f.j); /* { dg-warning "TRUE" } */
44 else
45 __analyzer_eval (f.j); /* { dg-warning "FALSE" } */
46 __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
49 void test_4 (struct coord *p)
51 struct coord f = *p;
52 f.x = 42;
53 __analyzer_eval (f.y == p->y); /* { dg-warning "TRUE" } */
54 __analyzer_eval (f.z == p->z); /* { dg-warning "TRUE" } */
57 struct s5
59 char arr[8];
62 void test_5 (struct s5 *p)
64 struct s5 f = *p;
65 f.arr[3] = 42;
66 __analyzer_eval (f.arr[0] == p->arr[0]); /* { dg-warning "TRUE" } */
67 __analyzer_eval (f.arr[1] == p->arr[1]); /* { dg-warning "TRUE" } */
68 __analyzer_eval (f.arr[2] == p->arr[2]); /* { dg-warning "TRUE" } */
69 __analyzer_eval (f.arr[3] == 42); /* { dg-warning "TRUE" } */
70 __analyzer_eval (f.arr[4] == p->arr[4]); /* { dg-warning "TRUE" } */
71 __analyzer_eval (f.arr[5] == p->arr[5]); /* { dg-warning "TRUE" } */
72 __analyzer_eval (f.arr[6] == p->arr[6]); /* { dg-warning "TRUE" } */
73 __analyzer_eval (f.arr[7] == p->arr[7]); /* { dg-warning "TRUE" } */
76 struct s6
78 int before; /* Give "arr" a nonzero offset. */
79 struct foo arr[4];
80 int after;
83 void test_6 (struct s6 *p, struct foo *q)
85 struct s6 f = *p;
86 f.arr[1] = *q;
87 __analyzer_eval (f.before == p->before); /* { dg-warning "TRUE" } */
88 __analyzer_eval (f.arr[0].i == p->arr[0].i); /* { dg-warning "TRUE" } */
89 __analyzer_eval (f.arr[0].j == p->arr[0].j); /* { dg-warning "TRUE" } */
90 __analyzer_eval (f.arr[1].i == q->i); /* { dg-warning "TRUE" } */
91 __analyzer_eval (f.arr[1].j == q->j); /* { dg-warning "TRUE" } */
92 __analyzer_eval (f.arr[2].i == p->arr[2].i); /* { dg-warning "TRUE" } */
93 __analyzer_eval (f.arr[2].j == p->arr[2].j); /* { dg-warning "TRUE" } */
94 __analyzer_eval (f.arr[3].i == p->arr[3].i); /* { dg-warning "TRUE" } */
95 __analyzer_eval (f.arr[3].j == p->arr[3].j); /* { dg-warning "TRUE" } */
96 __analyzer_eval (f.after == p->after); /* { dg-warning "TRUE" } */