/* >>>------------------------------------------------------------ * * File: rule_10.3.c, Module: M2CM-3.2-QAC-8.1.2 * * RULE 10.3 (Required): * The value of a complex expression of integer type shall only be * cast to a type of the same signedness that is no wider than the * underlying type of the expression. * * Implemented by messages: * 4118 Result of integer division operation cast to a floating * type. * * 4390 A composite expression of 'essentially signed' type * (%1s) is being cast to a wider signed type, '%2s'. * * 4391 A composite expression of 'essentially unsigned' type * (%1s) is being cast to a wider unsigned type, '%2s'. * * 4393 A composite expression of 'essentially signed' type * (%1s) is being cast to a different type category, '%2s'. * * 4394 A composite expression of 'essentially unsigned' type * (%1s) is being cast to a different type category, '%2s'. * * <<<------------------------------------------------------------ */ /* PRQA S 2982,3203 ++ */ #include "misra.h" #include "m2cmex.h" extern S16 test_1003( void ) { u8a = ( U8 )( u16a * u16b ); s16a = ( S16 )( s32a - 12345 ); s16b = ( S16 )( s32a * s32b ); u32a = ( U32 )u16a + u16b; u32b = ( U32 )u16a + ( U32 )u16b; s8r = ( S8 ) ( s32a + s32b ); s16r = ( S16 ) ( s32a + s32b ); s32r = ( S32 ) ( s32a + s32b ); s32a = (S32)(s16a * s16b); /* MISRA Violation */ u32a = (U32)(u16a + u16b); /* MISRA Violation */ u32r = ( U32 ) ( u16r >> 2 ); /* MISRA Violation */ s16r = ( S16 ) ( get_s8 ( ) + 1 ); /* MISRA Violation */ s8r = ( S8 ) ( u32a + u32b ); /* MISRA Violation */ s16r = ( S16 ) ( u32a + u32b ); /* MISRA Violation */ s32r = ( S32 ) ( u32a + u32b ); /* MISRA Violation */ u8r = ( U8 ) ( s32a + s32b ); /* MISRA Violation */ u16r = ( U16 ) ( s32a + s32b ); /* MISRA Violation */ u32r = ( U32 ) ( s32a + s32b ); /* MISRA Violation */ f32r = ( F32 ) ( s32a + s32b ); /* MISRA Violation */ f64r = ( F64 ) ( s32a + s32b ); /* MISRA Violation */ f32r = ( F32 ) (u32a / u32b); /* MISRA Violation */ return 0; }