1f08c3bdfSopenharmony_citypedef unsigned int u32; 2f08c3bdfSopenharmony_citypedef u32 __attribute__((bitwise)) __be32; 3f08c3bdfSopenharmony_ci 4f08c3bdfSopenharmony_ci/* Implicit casts of 0, legal */ 5f08c3bdfSopenharmony_cistatic __be32 foo(void) 6f08c3bdfSopenharmony_ci{ 7f08c3bdfSopenharmony_ci __be32 x = 0; 8f08c3bdfSopenharmony_ci 9f08c3bdfSopenharmony_ci return 0; 10f08c3bdfSopenharmony_ci} 11f08c3bdfSopenharmony_ci 12f08c3bdfSopenharmony_ci/* Explicit cast of 0, legal */ 13f08c3bdfSopenharmony_cistatic __be32 bar(void) 14f08c3bdfSopenharmony_ci{ 15f08c3bdfSopenharmony_ci return (__be32)0; 16f08c3bdfSopenharmony_ci} 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_ci/* Implicit casts of nonzero, bad */ 19f08c3bdfSopenharmony_cistatic __be32 baz(void) 20f08c3bdfSopenharmony_ci{ 21f08c3bdfSopenharmony_ci __be32 x = 0x2a; 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_ci return 99; 24f08c3bdfSopenharmony_ci} 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ci/* Explicit cast of nonzero, bad */ 27f08c3bdfSopenharmony_cistatic __be32 quux(void) 28f08c3bdfSopenharmony_ci{ 29f08c3bdfSopenharmony_ci return (__be32)1729; 30f08c3bdfSopenharmony_ci} 31f08c3bdfSopenharmony_ci 32f08c3bdfSopenharmony_ci/* Explicit case of nonzero forced, legal */ 33f08c3bdfSopenharmony_cistatic __be32 quuy(void) 34f08c3bdfSopenharmony_ci{ 35f08c3bdfSopenharmony_ci return (__attribute__((force)) __be32) 1730; 36f08c3bdfSopenharmony_ci} 37f08c3bdfSopenharmony_ci 38f08c3bdfSopenharmony_ci/* 39f08c3bdfSopenharmony_ci * check-name: conversions to bitwise types 40f08c3bdfSopenharmony_ci * check-command: sparse -Wbitwise $file 41f08c3bdfSopenharmony_ci * check-error-start 42f08c3bdfSopenharmony_cibitwise-cast.c:21:20: warning: incorrect type in initializer (different base types) 43f08c3bdfSopenharmony_cibitwise-cast.c:21:20: expected restricted __be32 [usertype] x 44f08c3bdfSopenharmony_cibitwise-cast.c:21:20: got int 45f08c3bdfSopenharmony_cibitwise-cast.c:23:16: warning: incorrect type in return expression (different base types) 46f08c3bdfSopenharmony_cibitwise-cast.c:23:16: expected restricted __be32 47f08c3bdfSopenharmony_cibitwise-cast.c:23:16: got int 48f08c3bdfSopenharmony_cibitwise-cast.c:29:17: warning: cast to restricted __be32 49f08c3bdfSopenharmony_ci * check-error-end 50f08c3bdfSopenharmony_ci */ 51