testsuite: Skip analyzer tests on AIX.
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / data-model-22.c
blob8429b2f4dc68de23c295e6841fa7530c294043cc
1 #include <string.h>
2 #include "analyzer-decls.h"
4 extern void check_init_char (char v);
5 extern void check_init_int (int v);
7 void test_1 (void)
9 union
11 char c[16];
12 int i[4];
13 } v;
14 memset (&v, 0, sizeof (v));
15 v.c[5] = 42;
16 check_init_int (v.c[0]);
17 check_init_int (v.c[4]);
18 check_init_int (v.c[6]);
19 check_init_int (v.i[1]);
22 void test_2 (void)
24 /* Intersection of byte ranges within "v". */
25 union
27 struct {
28 int a;
29 char b;
30 char c;
31 } __attribute__((packed)) icc;
32 struct {
33 char a;
34 int b;
35 char c;
36 } __attribute__((packed)) cic;
37 struct {
38 char a;
39 char b;
40 int c;
41 } __attribute__((packed)) cci;
42 } v;
44 v.icc.a = 1066;
45 v.icc.b = 42;
46 v.icc.c = 17;
48 __analyzer_eval (v.icc.a == 1066); /* { dg-warning "TRUE" } */
49 __analyzer_eval (v.icc.b == 42); /* { dg-warning "TRUE" } */
50 __analyzer_eval (v.icc.c == 17); /* { dg-warning "TRUE" } */
51 check_init_int (v.icc.a);
52 check_init_char (v.icc.b);
53 check_init_char (v.icc.c);
55 check_init_char (v.cic.a);
56 check_init_int (v.cic.b);
57 check_init_char (v.cic.c);
59 check_init_char (v.cci.a);
60 check_init_char (v.cci.b);
61 check_init_int (v.cci.c);
63 v.cic.a = 42;
64 v.cic.b = 1066;
65 v.cic.c = 17;
67 __analyzer_eval (v.cic.a == 42); /* { dg-warning "TRUE" } */
68 __analyzer_eval (v.cic.b == 1066); /* { dg-warning "TRUE" } */
69 __analyzer_eval (v.cic.c == 17); /* { dg-warning "TRUE" } */
70 check_init_int (v.icc.a);
71 check_init_char (v.icc.b);
72 check_init_char (v.icc.c);
74 check_init_char (v.cic.a);
75 check_init_int (v.cic.b);
76 check_init_char (v.cic.c);
78 check_init_char (v.cci.a);
79 check_init_char (v.cci.b);
80 check_init_int (v.cci.c);
82 v.cci.a = 42;
83 v.cci.b = 17;
84 v.cci.c = 1066;
86 __analyzer_eval (v.cci.a == 42); /* { dg-warning "TRUE" } */
87 __analyzer_eval (v.cci.b == 17); /* { dg-warning "TRUE" } */
88 __analyzer_eval (v.cci.c == 1066); /* { dg-warning "TRUE" } */
89 check_init_int (v.icc.a);
90 check_init_char (v.icc.b);
91 check_init_char (v.icc.c);
93 check_init_char (v.cic.a);
94 check_init_int (v.cic.b);
95 check_init_char (v.cic.c);
97 check_init_char (v.cci.a);
98 check_init_char (v.cci.b);
99 check_init_int (v.cci.c);