Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-bounds-49.c
blob9335f1507e8e33fb37a8ac75d0b5ac841807cb48
1 /* PR middle-end/91647 - missing -Warray-bounds accessing a zero-length array
2 of a declared object
3 { dg-do "compile" }
4 { dg-options "-O2 -Wall" } */
6 struct __attribute__ ((aligned (16))) A16
8 __INT64_TYPE__ i8;
9 __INT16_TYPE__ i2;
10 __INT16_TYPE__ a2[];
13 struct A16 a0 = { };
15 void test_a0 (void)
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 } };
27 void test_a1 (void)
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 } };
38 void test_a2 (void)
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 } };
49 void test_a3 (void)
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 } };
60 void test_a4 (void)
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 } };
71 void test_a5 (void)
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 } };
82 void test_a6 (void)
84 a6.a2[0] = 0; a6.a2[1] = 1; a6.a2[2] = 2; a6.a2[3] = 3; a6.a2[4] = 4;
85 a6.a2[5] = 5;
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 } };
94 void test_a7 (void)
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 } };
106 void test_a8 (void)
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 } };
118 void test_a9 (void)
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 }