Skip several analyzer socket tests on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / init.c
blobcd3c16f476627612b647d5685dc0385085cca364
1 /* Tests of brace-enclosed initializers
2 Some of these use the CONSTRUCTOR tree code, but it appears
3 only for a full zero-init; it appears that by the time the analyzer
4 runs that this initialization has been converted into field-wise
5 gimple assign stmts, with just "zero-init everything" CONSTRUCTORs
6 and "clobber" CONSTRUCTORs. */
8 #include "../../gcc.dg/analyzer/analyzer-decls.h"
10 struct coord
12 int x;
13 int y;
16 struct tri
18 struct coord v[3];
21 union iap
23 int i;
24 void *p;
27 void test_1 (void)
29 struct coord c = {3, 4};
30 __analyzer_eval (c.x == 3); /* { dg-warning "TRUE" } */
31 __analyzer_eval (c.y == 4); /* { dg-warning "TRUE" } */
34 void test_2 (void)
36 struct coord c = {3};
37 __analyzer_eval (c.x == 3); /* { dg-warning "TRUE" } */
38 __analyzer_eval (c.y == 0); /* { dg-warning "TRUE" } */
41 void test_3 (void)
43 struct coord c = {};
44 __analyzer_eval (c.x == 0); /* { dg-warning "TRUE" } */
45 __analyzer_eval (c.y == 0); /* { dg-warning "TRUE" } */
48 void test_4 (void)
50 int c[2] = {3, 4};
51 __analyzer_eval (c[0] == 3); /* { dg-warning "TRUE" } */
52 __analyzer_eval (c[1] == 4); /* { dg-warning "TRUE" } */
55 void test_5 (void)
57 int c[2] = {3};
58 __analyzer_eval (c[0] == 3); /* { dg-warning "TRUE" } */
59 __analyzer_eval (c[1] == 0); /* { dg-warning "TRUE" } */
62 void test_6 (void)
64 int c[2] = {};
65 __analyzer_eval (c[0] == 0); /* { dg-warning "TRUE" } */
66 __analyzer_eval (c[1] == 0); /* { dg-warning "TRUE" } */
69 void test_7 (void)
71 struct coord c[2] = {{3, 4}, {5, 6}};
72 __analyzer_eval (c[0].x == 3); /* { dg-warning "TRUE" } */
73 __analyzer_eval (c[0].y == 4); /* { dg-warning "TRUE" } */
74 __analyzer_eval (c[1].x == 5); /* { dg-warning "TRUE" } */
75 __analyzer_eval (c[1].y == 6); /* { dg-warning "TRUE" } */
78 void test_8 (void)
80 struct coord c[2] = {{3}, {5}};
81 __analyzer_eval (c[0].x == 3); /* { dg-warning "TRUE" } */
82 __analyzer_eval (c[0].y == 0); /* { dg-warning "TRUE" } */
83 __analyzer_eval (c[1].x == 5); /* { dg-warning "TRUE" } */
84 __analyzer_eval (c[1].y == 0); /* { dg-warning "TRUE" } */
87 void test_9 (void)
89 struct coord c[2] = {{}, {}};
90 __analyzer_eval (c[0].x == 0); /* { dg-warning "TRUE" } */
91 __analyzer_eval (c[0].y == 0); /* { dg-warning "TRUE" } */
92 __analyzer_eval (c[1].x == 0); /* { dg-warning "TRUE" } */
93 __analyzer_eval (c[1].y == 0); /* { dg-warning "TRUE" } */
96 void test_10 (void)
98 struct coord c[2] = {{.x = 3, .y = 4}, {5, 6}};
99 __analyzer_eval (c[0].x == 3); /* { dg-warning "TRUE" } */
100 __analyzer_eval (c[0].y == 4); /* { dg-warning "TRUE" } */
101 __analyzer_eval (c[1].x == 5); /* { dg-warning "TRUE" } */
102 __analyzer_eval (c[1].y == 6); /* { dg-warning "TRUE" } */
105 void test_11 (void)
107 struct coord c[2] = {{.y = 4}, {5, 6}};
108 __analyzer_eval (c[0].x == 0); /* { dg-warning "TRUE" } */
109 __analyzer_eval (c[0].y == 4); /* { dg-warning "TRUE" } */
110 __analyzer_eval (c[1].x == 5); /* { dg-warning "TRUE" } */
111 __analyzer_eval (c[1].y == 6); /* { dg-warning "TRUE" } */
114 void test_12 (void)
116 struct tri t = {};
117 __analyzer_eval (t.v[0].x == 0); /* { dg-warning "TRUE" } */
118 __analyzer_eval (t.v[2].y == 0); /* { dg-warning "TRUE" } */
121 void test_13 (void)
123 struct tri t = {3, 4, 5, 6, 7, 8};
124 __analyzer_eval (t.v[0].x == 3); /* { dg-warning "TRUE" } */
125 __analyzer_eval (t.v[0].y == 4); /* { dg-warning "TRUE" } */
126 __analyzer_eval (t.v[1].x == 5); /* { dg-warning "TRUE" } */
127 __analyzer_eval (t.v[1].y == 6); /* { dg-warning "TRUE" } */
128 __analyzer_eval (t.v[2].x == 7); /* { dg-warning "TRUE" } */
129 __analyzer_eval (t.v[2].y == 8); /* { dg-warning "TRUE" } */
132 void test_14 (void)
134 union iap u = {};
135 __analyzer_eval (u.i == 0); /* { dg-warning "TRUE" } */