Debian Codegraph @

gcc/testsuite/gcc.dg/c23-tag-alias-6.c

raw
1 /* { dg-do run }
2 * { dg-options "-std=c23 -O2" }
3 */
4
5
6 /* These tests check that a composite type for a struct
7 * can alias the original definition. */
8
9 struct foo { int (*y)[]; int x; } s;
10
11 int test_foo(struct foo* a, void* b)
12 {
13 a->x = 1;
14
15 struct foo { int (*y)[1]; int x; } t;
16 typeof(*(1 ? &s: &t)) *p = b;
17 p->x = 2;
18
19 return a->x;
20 }
21
22
23 int main()
24 {
25 struct foo y;
26
27 if (2 != test_foo(&y, &y))
28 __builtin_abort();
29
30 return 0;
31 }
32