libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-bounds-51.c
blob7519b0fed79deb52be3c61c0c4f3a5b092ce8099
1 /* PR middle-end/92333 - missing variable name referencing VLA in warnings
2 PR middle-end/82608 - missing -Warray-bounds on an out-of-bounds VLA index
3 { dg-do compile }
4 { dg-options "-O2 -Wall" }
5 { dg-additional-options "-mtune=generic" { target { i?86-*-* x86_64-*-* } } } */
7 void sink (void*);
9 void test_char_vla_location (void)
11 unsigned nelts = 7;
13 char vla[nelts]; // { dg-message "declared here|while referencing" }
15 vla[0] = __LINE__;
16 vla[nelts] = 0; // { dg-warning "\\\[-Warray-bounds" }
18 sink (vla);
21 void test_int_vla_location (void)
23 unsigned nelts = 7;
25 int vla[nelts]; // { dg-message "declared here|while referencing" }
27 vla[0] = __LINE__;
28 vla[nelts] = 1; // { dg-warning "\\\[-Warray-bounds" }
30 sink (vla);
33 void test_struct_char_vla_location (void)
35 unsigned nelts = 7;
37 struct {
38 char cvla[nelts]; // { dg-message "declared here|while referencing" }
39 } s;
41 s.cvla[0] = __LINE__;
42 s.cvla[nelts - 1] = 0; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2qi_store_align } } }
43 s.cvla[nelts] = 0; // { dg-warning "\\\[-Warray-bounds" }
45 sink (&s);
49 void test_struct_int_vla_location (void)
51 unsigned nelts = 7;
53 struct {
54 int ivla[nelts]; // { dg-message "declared here|while referencing" }
55 } s;
57 s.ivla[0] = __LINE__;
58 s.ivla[nelts - 1] = 0;
59 s.ivla[nelts] = 0; // { dg-warning "\\\[-Warray-bounds" }
61 sink (&s);