testsuite: Add -Wno-psabi to pr104505.c
[official-gcc.git] / gcc / testsuite / c-c++-common / Warray-bounds-10.c
blobcfe9a38341087e010a7e883afe9ca74808b587a1
1 /* PR tree-optimization/99475 - bogus -Warray-bounds accessing an array
2 element of empty structs
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
6 struct S
8 #if SOME_CONFIG_MACRO
9 /* Suppose the contents are empty in the development configuration
10 but non-empty in others. Out of bounds accesses to elements of
11 the arrays below should be diagnosed in all configurations,
12 including when S is empty, even if they are folded away. */
13 int member;
14 #endif
17 extern struct S sa3[3];
18 extern struct S sa2_3[2][3];
19 extern struct S sa3_4_5[3][4][5];
21 void sink (void*);
24 void access_sa3 (struct S s)
26 sa3[0] = s;
27 sa3[1] = s;
28 sa3[2] = s;
29 sa3[3] = s; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
32 void access_sa3_ptr (struct S s)
34 struct S *p = &sa3[0];
36 p[0] = s; // { dg-bogus "\\\[-Warray-bounds" }
37 p[1] = s; // { dg-bogus "\\\[-Warray-bounds" }
38 p[2] = s; // { dg-bogus "\\\[-Warray-bounds" }
39 p[3] = s; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
42 void access_sa2_3_ptr (struct S s)
44 struct S *p = &sa2_3[0][0];
46 p[0] = s; // { dg-bogus "\\\[-Warray-bounds" }
47 p[1] = s; // { dg-bogus "\\\[-Warray-bounds" }
48 p[2] = s; // { dg-bogus "\\\[-Warray-bounds" }
49 p[6] = s; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
52 void access_sa3_4_5_ptr (struct S s, int i)
54 struct S *p = &sa3_4_5[0][0][0];
56 p[0] = s; // { dg-bogus "\\\[-Warray-bounds" }
57 p[1] = s; // { dg-bogus "\\\[-Warray-bounds" }
58 p[2] = s; // { dg-bogus "\\\[-Warray-bounds" }
59 p[60] = s; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
63 void access_vla3 (struct S s, unsigned n)
65 struct S vla3[3 < n ? 3 : n];
67 vla3[0] = s;
68 vla3[1] = s;
69 vla3[2] = s;
70 vla3[3] = s; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
72 sink (vla3);
75 void access_vla3_ptr (struct S s, unsigned n)
77 struct S vla3[3 < n ? 3 : n];
78 struct S *p = &vla3[0];
80 p[0] = s; // { dg-bogus "\\\[-Warray-bounds" }
81 p[1] = s; // { dg-bogus "\\\[-Warray-bounds" }
82 p[2] = s; // { dg-bogus "\\\[-Warray-bounds" }
83 p[3] = s; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
85 sink (vla3);
88 void access_vla2_3_ptr (struct S s, unsigned n)
90 struct S vla2_3[2 < n ? 2 : n][3 < n ? 3 : n];
91 struct S *p = &vla2_3[0][0];
93 p[0] = s; // { dg-bogus "\\\[-Warray-bounds" }
94 p[1] = s; // { dg-bogus "\\\[-Warray-bounds" }
95 p[2] = s; // { dg-bogus "\\\[-Warray-bounds" }
96 p[6] = s; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
98 sink (vla2_3);
101 void access_vla3_4_5_ptr (struct S s, unsigned n)
103 struct S vla3_4_5[3 < n ? 3 : n][4 < n ? 4 : n][5 < n ? 5 : n];
104 struct S *p = &vla3_4_5[0][0][0];
106 p[0] = s; // { dg-bogus "\\\[-Warray-bounds" }
107 p[1] = s; // { dg-bogus "\\\[-Warray-bounds" }
108 p[2] = s; // { dg-bogus "\\\[-Warray-bounds" }
109 p[60] = s; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
111 sink (vla3_4_5);
114 // { dg-prune-output "empty struct has size 0 in C" }