Debian Codegraph @

gcc/testsuite/gcc.dg/cpp/embed-8.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-std=c23" } */
3
4 unsigned char a[] = {
5 #embed __FILE__
6 };
7 unsigned char b[] = {
8 [26] =
9 #embed __FILE__
10 };
11 unsigned char c[] = {
12 #embed __FILE__ suffix (,)
13 [sizeof (a) / 4] = 0,
14 [sizeof (a) / 2] = 1,
15 [1] = 2,
16 [sizeof (a) - 2] = 3
17 };
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] = )
25 };
26 unsigned char e[] = {
27 #embed __FILE__ suffix (,)
28 [2] = 9,
29 [sizeof (a) - 3] = 10
30 };
31 unsigned char f[] = {
32 [23] = 11,
33 [sizeof (a) / 4 - 1] = 12,
34 #embed __FILE__ limit (128) prefix ([sizeof (a) / 4 - 1] = ) suffix (,)
35 #embed __FILE__ limit (130) prefix ([sizeof (a) / 4 - 2] = ) suffix (,)
36 #embed __FILE__ prefix ([sizeof (a) / 4 + 10] = ) suffix (,)
37 #embed __FILE__ limit (128) prefix ([sizeof (a) + sizeof (a) / 4 - 30] = ) suffix (,)
38 #embed __FILE__ limit (128) prefix ([sizeof (a) / 4 + 96] = ) suffix (,)
39 };
40 const unsigned char g[] = {
41 #embed __FILE__ limit (128) prefix ( [10] = 2, [5] = 3, [13] = 4, [17] = 5, [0] = )
42 };
43 unsigned char z[sizeof (a) / 4] = {
44 };
45
46 int
47 main ()
48 {
49 if (sizeof (b) != sizeof (a) + 26
50 || __builtin_memcmp (a, b + 26, sizeof (a)))
51 __builtin_abort ();
52 if (sizeof (c) != sizeof (a)
53 || a[0] != c[0]
54 || c[1] != 2
55 || __builtin_memcmp (a + 2, c + 2, sizeof (a) / 4 - 2)
56 || c[sizeof (a) / 4] != 0
57 || __builtin_memcmp (a + sizeof (a) / 4 + 1, c + sizeof (a) / 4 + 1, sizeof (a) / 2 - sizeof (a) / 4 - 1)
58 || c[sizeof (a) / 2] != 1
59 || __builtin_memcmp (a + sizeof (a) / 2 + 1, c + sizeof (a) / 2 + 1, sizeof (a) - sizeof (a) / 2 - 3)
60 || c[sizeof (a) - 2] != 3
61 || a[sizeof (a) - 1] != c[sizeof (a) - 1])
62 __builtin_abort ();
63 if (sizeof (d) != sizeof (a)
64 || __builtin_memcmp (a, d, sizeof (a)))
65 __builtin_abort ();
66 if (sizeof (e) != sizeof (a)
67 || a[0] != e[0]
68 || a[1] != e[1]
69 || e[2] != 9
70 || __builtin_memcmp (a + 3, e + 3, sizeof (a) - 6)
71 || e[sizeof (a) - 3] != 10
72 || a[sizeof (a) - 2] != e[sizeof (a) - 2]
73 || a[sizeof (a) - 1] != e[sizeof (a) - 1])
74 __builtin_abort ();
75 if (sizeof (f) != sizeof (a) + sizeof (a) / 4 - 30 + 128
76 || __builtin_memcmp (z, f, 23)
77 || f[23] != 11
78 || __builtin_memcmp (z, f + 24, sizeof (a) / 4 - 2 - 24)
79 || __builtin_memcmp (f + sizeof (a) / 4 - 2, a, 12)
80 || __builtin_memcmp (f + sizeof (a) / 4 + 10, a, 86)
81 || __builtin_memcmp (f + sizeof (a) / 4 + 96, a, 128)
82 || __builtin_memcmp (f + sizeof (a) / 4 + 96 + 128, a + 86 + 128, sizeof (a) - 86 - 128 - 40)
83 || __builtin_memcmp (f + sizeof (a) + sizeof (a) / 4 - 30, a, 128))
84 __builtin_abort ();
85 if (sizeof (g) != 128 || __builtin_memcmp (g, a, 128))
86 __builtin_abort ();
87 }