xref: /third_party/ltp/tools/sparse/sparse-src/validation/pure-function.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/ltp/tools/sparse/sparse-src/validation/
1f08c3bdfSopenharmony_ci
2f08c3bdfSopenharmony_cistatic __attribute__((__pure__)) int pure_int(int v)
3f08c3bdfSopenharmony_ci{
4f08c3bdfSopenharmony_ci	int i = v;
5f08c3bdfSopenharmony_ci	return i;
6f08c3bdfSopenharmony_ci}
7f08c3bdfSopenharmony_ci
8f08c3bdfSopenharmony_cistatic __attribute__((__pure__)) void *pure_ptr(void *p)
9f08c3bdfSopenharmony_ci{
10f08c3bdfSopenharmony_ci    void *i = p;
11f08c3bdfSopenharmony_ci    return i;
12f08c3bdfSopenharmony_ci}
13f08c3bdfSopenharmony_ci
14f08c3bdfSopenharmony_cistatic void foo(int v, void *p)
15f08c3bdfSopenharmony_ci{
16f08c3bdfSopenharmony_ci	int   val = pure_int(v);
17f08c3bdfSopenharmony_ci	void *ptr = pure_ptr(p);
18f08c3bdfSopenharmony_ci
19f08c3bdfSopenharmony_ci	(void)val;
20f08c3bdfSopenharmony_ci	(void)ptr;
21f08c3bdfSopenharmony_ci}
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_ci/*
24f08c3bdfSopenharmony_ci * check-name: Pure function attribute
25f08c3bdfSopenharmony_ci */
26

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