xref: /third_party/ltp/tools/sparse/sparse-src/validation/packed-bitfield1.c (revision f08c3bdf)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/ltp/tools/sparse/sparse-src/validation/
1f08c3bdfSopenharmony_ci#define __packed	__attribute__((packed))
2f08c3bdfSopenharmony_ci
3f08c3bdfSopenharmony_cistruct s {
4f08c3bdfSopenharmony_ci	unsigned int f0:1;
5f08c3bdfSopenharmony_ci	unsigned int f1:1;
6f08c3bdfSopenharmony_ci	unsigned int pad:6;
7f08c3bdfSopenharmony_ci} __packed;
8f08c3bdfSopenharmony_ci_Static_assert(sizeof(struct s) == 1,  "sizeof(struct s)");
9f08c3bdfSopenharmony_ci
10f08c3bdfSopenharmony_ciextern struct s g;
11f08c3bdfSopenharmony_ci
12f08c3bdfSopenharmony_cistatic int foo(struct s *ptr)
13f08c3bdfSopenharmony_ci{
14f08c3bdfSopenharmony_ci	int f = 0;
15f08c3bdfSopenharmony_ci
16f08c3bdfSopenharmony_ci	f += g.f0;
17f08c3bdfSopenharmony_ci	f += g.f1;
18f08c3bdfSopenharmony_ci
19f08c3bdfSopenharmony_ci	f += ptr->f0;
20f08c3bdfSopenharmony_ci	f += ptr->f1;
21f08c3bdfSopenharmony_ci
22f08c3bdfSopenharmony_ci	return f;
23f08c3bdfSopenharmony_ci}
24f08c3bdfSopenharmony_ci
25f08c3bdfSopenharmony_ci/*
26f08c3bdfSopenharmony_ci * check-name: packed-bitfield1
27f08c3bdfSopenharmony_ci */
28

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