Debian Codegraph @

gcc/testsuite/gcc.dg/c23-tag-5.c

raw
1 /* { dg-do run }
2 * { dg-options "-std=c23 -fpermissive" }
3 */
4
5 // nesting and parameters
6
7 #define product_type(T, A, B) \
8 struct product_ ## T { A a ; B b ; }
9 #define sum_type(T, A, B) \
10 struct sum_ ## T { _Bool flag ; union { A a ; B b ; }; }
11
12 float foo1(product_type(iSfd_, int, sum_type(fd, float, double)) x)
13 {
14 return x.b.a;
15 }
16
17 static void test1(void)
18 {
19 product_type(iSfd_, int, sum_type(fd, float, double)) y = { 3, { 1, { .a = 1. } } };
20 product_type(iSfd_, int, sum_type(fd, float, double)) z = y;
21 product_type(iSfd_, int, sum_type(fd, float, double)) *zp = &y;
22 float a = foo1(y);
23 product_type(iSid_, int, sum_type(id, int, double)) *wp = &y; /* { dg-warning "incompatible pointer type" } */
24 float b = foo1(y);
25 product_type(iSid_, int, sum_type(id, int, double)) w = *wp;
26 (void)a; (void)b; (void)z; (void)zp; (void)w; (void)wp;
27 }
28
29 int main()
30 {
31 test1();
32 }
33