xref: /third_party/ltp/tools/sparse/sparse-src/validation/transparent-union.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/ltp/tools/sparse/sparse-src/validation/
1f08c3bdfSopenharmony_cistruct a {
2f08c3bdfSopenharmony_ci	int field;
3f08c3bdfSopenharmony_ci};
4f08c3bdfSopenharmony_cistruct b {
5f08c3bdfSopenharmony_ci	int field;
6f08c3bdfSopenharmony_ci};
7f08c3bdfSopenharmony_ci
8f08c3bdfSopenharmony_citypedef union {
9f08c3bdfSopenharmony_ci	struct a *a;
10f08c3bdfSopenharmony_ci	struct b *b;
11f08c3bdfSopenharmony_ci} transparent_arg __attribute__((__transparent_union__));
12f08c3bdfSopenharmony_ci
13f08c3bdfSopenharmony_cistatic void foo(transparent_arg arg)
14f08c3bdfSopenharmony_ci{
15f08c3bdfSopenharmony_ci}
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_cistatic void bar(void)
18f08c3bdfSopenharmony_ci{
19f08c3bdfSopenharmony_ci	struct b arg = { 0 };
20f08c3bdfSopenharmony_ci	foo((struct a *) &arg);
21f08c3bdfSopenharmony_ci}
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_ci/*
24f08c3bdfSopenharmony_ci * check-name: Transparent union attribute.
25f08c3bdfSopenharmony_ci */
26

Indexes created Thu Nov 07 10:32:03 CST 2024