libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / cpp / embed-9.c
blob677540a14398b3f026be7e7d64e50aacd8e5d66b
1 /* { dg-do compile } */
2 /* { dg-options "-std=c23 -Woverride-init" } */
4 unsigned char a[] = {
5 #embed __FILE__
6 };
7 unsigned char b[] = {
8 [26] =
9 #embed __FILE__
11 unsigned char c[] = {
12 #embed __FILE__ suffix (,)
13 [sizeof (a) / 4] = 0, /* { dg-warning "initialized field overwritten" } */
14 [sizeof (a) / 2] = 1, /* { dg-warning "initialized field overwritten" } */
15 [1] = 2, /* { dg-warning "initialized field overwritten" } */
16 [sizeof (a) - 2] = 3 /* { dg-warning "initialized field overwritten" } */
18 unsigned char d[] = {
19 [1] = 4,
20 [26] = 5,
21 [sizeof (a) / 4] = 6,
22 [sizeof (a) / 2] = 7,
23 [sizeof (a) - 2] = 8,
24 #embed __FILE__ prefix ([0] = ) /* { dg-warning "initialized field overwritten" } */
26 unsigned char e[] = {
27 #embed __FILE__ suffix (,)
28 [2] = 9, /* { dg-warning "initialized field overwritten" } */
29 [sizeof (a) - 3] = 10 /* { dg-warning "initialized field overwritten" } */
31 unsigned char f[] = {
32 [23] = 11,
33 [sizeof (a) / 4 - 1] = 12,
34 #embed __FILE__ limit (128) prefix ([sizeof (a) / 4 - 1] = ) suffix (,) /* { dg-warning "initialized field overwritten" } */
35 #embed __FILE__ limit (130) prefix ([sizeof (a) / 4 - 2] = ) suffix (,) /* { dg-warning "initialized field overwritten" } */
36 #embed __FILE__ prefix ([sizeof (a) / 4 + 10] = ) suffix (,) /* { dg-warning "initialized field overwritten" } */
37 #embed __FILE__ limit (128) prefix ([sizeof (a) + sizeof (a) / 4 - 30] = ) suffix (,) /* { dg-warning "initialized field overwritten" } */
38 #embed __FILE__ limit (128) prefix ([sizeof (a) / 4 + 96] = ) suffix (,) /* { dg-warning "initialized field overwritten" } */
40 const unsigned char g[] = {
41 #embed __FILE__ limit (128) prefix ( [10] = 2, [5] = 3, [13] = 4, [17] = 5, [0] = ) /* { dg-warning "initialized field overwritten" } */