Abraxas/Misra Home  Table of Contents

Module - m39.html

ABRAXAS SOFTWARE - CodeCheck MISRA Test-Suite Misra-C:1998 Misra-C:2004.

Misra-C Test Suite for Module - m39.c

/* Misra C Enforcement Testing */

Misra C Enforcement Testing */

/* Rule 39: Required */

Rule 39: Required */

/* The unary minus operator shall not be applied to an unsigned */

The unary minus operator shall not be applied to an unsigned */

/* expression. */

expression. */
#include "misra.h"
SI_32
rule39 ( void ) 



Function Name: rule39()

{
    
UI_32 a = 3;
SI_64 b = 3;
UI_64 d = 3;
UI_16 e = 3;
    
SI_32 c = 3;
    
    if ( sizeof ( short ) == sizeof ( int ) ) 
    {
        
        a = - e; 
        
    }
    else if ( sizeof ( unsigned int ) == sizeof ( long ) ) 
    {
        
        d = - ( a + b ) ; /*  RULE 39  */
        
    }
    else
    {
        

/* error - Test failed. */

error - Test failed. */
        
    }
    
    return c;
    
}

Abraxas/Misra Home  Table of Contents

ABRAXAS SOFTWARE - CodeCheck MISRA Test-Suite Misra-C:1998 Misra-C:2004.