Require target lto in several tests
[official-gcc.git] / gcc / testsuite / gcc.dg / c23-tag-alias-2.c
blob1a4097b629da7c12a01e9d8edb0669a7d111e376
1 /* { dg-do run { target lto } }
2 * { dg-options "-std=c23 -flto -O2" }
3 */
5 /* These tests check that compatible definitions of
6 tagged types can alias the original definitions
7 with LTO. */
9 struct foo { int x; };
11 int test_foo(struct foo* a, void* b)
13 a->x = 1;
15 struct foo { int x; }* p = b;
16 p->x = 2;
18 return a->x;
22 enum bar { A = 1, B = 3 };
24 int test_bar(enum bar* a, void* b)
26 *a = A;
28 enum bar { A = 1, B = 3 }* p = b;
29 *p = B;
31 return *a;
35 int main()
37 struct foo y;
39 if (2 != test_foo(&y, &y))
40 __builtin_abort();
42 enum bar z;
44 if (B != test_bar(&z, &z))
45 __builtin_abort();
47 return 0;