1 /* PR middle-end/91647 - missing -Warray-bounds accessing a zero-length array
4 { dg-options "-O2 -Wall" } */
6 struct __attribute__ ((aligned (16))) A16
17 // The first three elements fit in the tail padding.
18 a0
.a2
[0] = 0; a0
.a2
[1] = 1; a0
.a2
[2] = 2;
20 a0
.a2
[3] = 3; // { dg-warning "array subscript 3 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } }
21 // { dg-warning "array subscript 3 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 }
25 struct A16 a1
= { .a2
= { 1 } };
29 a1
.a2
[0] = 0; a1
.a2
[1] = 1; a1
.a2
[2] = 2;
31 a1
.a2
[3] = 3; // { dg-warning "array subscript 3 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } }
32 // { dg-warning "array subscript 3 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 }
36 struct A16 a2
= { .a2
= { 1, 2 } };
40 a2
.a2
[0] = 0; a2
.a2
[1] = 1; a2
.a2
[2] = 2;
42 a2
.a2
[3] = 3; // { dg-warning "array subscript 3 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } }
43 // { dg-warning "array subscript 3 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 }
47 struct A16 a3
= { .a2
= { 1, 2, 3 } };
51 a3
.a2
[0] = 0; a3
.a2
[1] = 1; a3
.a2
[2] = 2;
53 a3
.a2
[3] = 3; // { dg-warning "array subscript 3 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } }
54 // { dg-warning "array subscript 3 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 }
58 struct A16 a4
= { .a2
= { 1, 2, 3, 4 } };
62 a4
.a2
[0] = 0; a4
.a2
[1] = 1; a4
.a2
[2] = 2; a4
.a2
[3] = 3;
64 a4
.a2
[4] = 4; // { dg-warning "array subscript 4 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } }
65 // { dg-warning "array subscript 4 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 }
69 struct A16 a5
= { .a2
= { 1, 2, 3, 4, 5 } };
73 a5
.a2
[0] = 0; a5
.a2
[1] = 1; a5
.a2
[2] = 2; a5
.a2
[3] = 3; a5
.a2
[4] = 4;
75 a5
.a2
[5] = 5; // { dg-warning "array subscript 5 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } }
76 // { dg-warning "array subscript 5 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 }
80 struct A16 a6
= { .a2
= { 1, 2, 3, 4, 5, 6 } };
84 a6
.a2
[0] = 0; a6
.a2
[1] = 1; a6
.a2
[2] = 2; a6
.a2
[3] = 3; a6
.a2
[4] = 4;
87 a6
.a2
[6] = 6; // { dg-warning "array subscript 6 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } }
88 // { dg-warning "array subscript 6 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 }
92 struct A16 a7
= { .a2
= { 1, 2, 3, 4, 5, 6, 7 } };
96 a7
.a2
[0] = 0; a7
.a2
[1] = 1; a7
.a2
[2] = 2; a7
.a2
[3] = 3; a7
.a2
[4] = 4;
97 a7
.a2
[5] = 5; a7
.a2
[5] = 5; a7
.a2
[6] = 6;
99 a7
.a2
[7] = 7; // { dg-warning "array subscript 7 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } }
100 // { dg-warning "array subscript 7 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 }
104 struct A16 a8
= { .a2
= { 1, 2, 3, 4, 5, 6, 7, 8 } };
108 a8
.a2
[0] = 0; a8
.a2
[1] = 1; a8
.a2
[2] = 2; a8
.a2
[3] = 3; a8
.a2
[4] = 4;
109 a8
.a2
[5] = 5; a8
.a2
[5] = 5; a8
.a2
[6] = 6; a8
.a2
[7] = 7;
111 a8
.a2
[8] = 8; // { dg-warning "array subscript 8 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } }
112 // { dg-warning "array subscript 8 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 }
116 struct A16 a9
= { .a2
= { 1, 2, 3, 4, 5, 6, 7, 8, 9 } };
120 a8
.a2
[0] = 8; a8
.a2
[1] = 7; a8
.a2
[2] = 6; a8
.a2
[3] = 5; a8
.a2
[4] = 4;
121 a8
.a2
[5] = 3; a8
.a2
[5] = 2; a8
.a2
[6] = 1; a8
.a2
[7] = 0;
123 a8
.a2
[9] = 8; // { dg-warning "array subscript 9 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } }
124 // { dg-warning "array subscript 9 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 }