xref: /third_party/ltp/tools/sparse/sparse-src/validation/packed-deref0.c
  • 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_citypedef struct {
4f08c3bdfSopenharmony_ci	__INT8_TYPE__	a;
5f08c3bdfSopenharmony_ci	__INT16_TYPE__	b;
6f08c3bdfSopenharmony_ci	__INT32_TYPE__	c;
7f08c3bdfSopenharmony_ci} __packed obj_t;
8f08c3bdfSopenharmony_ci
9f08c3bdfSopenharmony_ci_Static_assert(sizeof(obj_t) == 7, "sizeof packed struct");
10f08c3bdfSopenharmony_ci
11f08c3bdfSopenharmony_cistatic void foo(obj_t *ptr, int val)
12f08c3bdfSopenharmony_ci{
13f08c3bdfSopenharmony_ci	ptr->c = val;
14f08c3bdfSopenharmony_ci}
15f08c3bdfSopenharmony_ci
16f08c3bdfSopenharmony_cistatic void bar(obj_t o)
17f08c3bdfSopenharmony_ci{
18f08c3bdfSopenharmony_ci	foo(&o, 0);
19f08c3bdfSopenharmony_ci}
20f08c3bdfSopenharmony_ci
21f08c3bdfSopenharmony_ci/*
22f08c3bdfSopenharmony_ci * check-name: packed-deref0
23f08c3bdfSopenharmony_ci */
24

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