1f08c3bdfSopenharmony_ci#define __bitwise	__attribute__((bitwise))
2f08c3bdfSopenharmony_ci#define __force		__attribute__((force))
3f08c3bdfSopenharmony_ci
4f08c3bdfSopenharmony_citypedef unsigned int u32;
5f08c3bdfSopenharmony_citypedef unsigned int __bitwise __be32;
6f08c3bdfSopenharmony_ci
7f08c3bdfSopenharmony_cistatic __be32* tobi(u32 *x)
8f08c3bdfSopenharmony_ci{
9f08c3bdfSopenharmony_ci	return x;			// should warn, implicit cast
10f08c3bdfSopenharmony_ci}
11f08c3bdfSopenharmony_ci
12f08c3bdfSopenharmony_cistatic __be32* tobe(u32 *x)
13f08c3bdfSopenharmony_ci{
14f08c3bdfSopenharmony_ci	return (__be32 *) x;		// should warn, explicit cast
15f08c3bdfSopenharmony_ci}
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_cistatic __be32* tobf(u32 *x)
18f08c3bdfSopenharmony_ci{
19f08c3bdfSopenharmony_ci	return (__force __be32 *) x;	// should not warn, forced cast
20f08c3bdfSopenharmony_ci	return (__be32 __force *) x;	// should not warn, forced cast
21f08c3bdfSopenharmony_ci}
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_ci/*
24f08c3bdfSopenharmony_ci * check-name: cast of bitwise pointers
25f08c3bdfSopenharmony_ci * check-command: sparse -Wbitwise -Wbitwise-pointer $file
26f08c3bdfSopenharmony_ci *
27f08c3bdfSopenharmony_ci * check-error-start
28f08c3bdfSopenharmony_cibitwise-cast-ptr.c:9:16: warning: incorrect type in return expression (different base types)
29f08c3bdfSopenharmony_cibitwise-cast-ptr.c:9:16:    expected restricted __be32 [usertype] *
30f08c3bdfSopenharmony_cibitwise-cast-ptr.c:9:16:    got unsigned int [usertype] *x
31f08c3bdfSopenharmony_cibitwise-cast-ptr.c:14:17: warning: cast to restricted __be32 [usertype] *
32f08c3bdfSopenharmony_ci * check-error-end
33f08c3bdfSopenharmony_ci */
34