This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MISRA checks for rule 14.7 cannot be turned off

Other Parts Discussed in Thread: CONTROLSUITE

I have some functions with extensive parameter checking where obeying misra rule 14.7 (single exit point) would result in unwieldy, difficult to follow code with a huge number of indentations.

I try to turn off this check using "#pragma CHECK_MISRA("-14.7")" but the error is still reported (but only at the first instance of a return statement.

compiler ARM v5.0.1

  • Andy,

    Would you be able to provide a simple test case that reproduces the issue (along with complete set of compiler options used for the build) so we can confirm if there is a bug and submit a bug report to get this addressed?

  • typedef signed int int32;

    typedef unsigned int uint32;

    uint32 function(int32 Y, int32Z);

    int32 A;

    int32 B;

    uint32 function(int32 Y, int32Z)

    {

    /* a pointless function just to demo the compiler problem */

    #pragma CHECK_MISRA("-14.7")

    if (Z == 0)

    {

    return 0U; /* misra violation 14.7 flagged here */

    }

    if(Y == 0)

    {

    return 0U;

    }

    A = (Y*10) / Z;

    B = (Z*10) / Y;

    return 1U;

    #pragma CHECK_MISRA("14.7")

    }

    Enviroment CCS V5.3.00090

    TI v5.0.1 compiler for the Concerto F28MH52C1 (ARM M3 processor )

    compiler flags

    -mv7M3 --code_state=16 --abi=eabi -me -g --include_path="C:/ti/controlSUITE/device_support/f28m35x/v130/MWare" --include_path="C:/ti/ccsv5.3/ccsv5/tools/compiler/arm_5.0.1/include" --include_path="C:/ti/FlashAPI" --check_misra="all,-5.6,-5.7,-19.7" --gcc --define=ccs --diag_warning=225 --display_error_number --gen_func_subsections=on --ual

  • It looks like the pragma applies at the function level. If the line #pragma CHECK_MISRA("14.7") to re-enable the check is moved outside the function then the misra check is correctly disabled within the function, as expected.

    uint32 function(int32 Y, int32 Z)

    {

    /* a pointless function just to demo the compiler problem */

    #pragma CHECK_MISRA("-14.7") 
    if (Z == 0)
    {
    return 0U; /* misra violation 14.7 flagged here */
    }

    if(Y == 0)
    {
    return 0U;
    }

    A = (Y*10) / Z;
    B = (Z*10) / Y;

    return 1U;
     
    }

    #pragma CHECK_MISRA("14.7")