[SOLVED] Static code analyzer ignores "v8M Has CMSE" option

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Static code analyzer ignores "v8M Has CMSE" option

    When "v8M Has CMSE Instructions" is set to Yes in the project configuration, the preprocessor constant __ARM_FEATURE_CMSE is set differently when compiling (gcc) and when running code analyzer.

    The following code produces value 3 (correct) at the compilation stage but value 1 (incorrect) at the code analysis stage.

    C Source Code

    1. #if !defined(__ARM_FEATURE_CMSE)
    2. #warning CMSE is disabled
    3. #elif __ARM_FEATURE_CMSE == 1
    4. #warning CMSE is 1
    5. #elif __ARM_FEATURE_CMSE == 3
    6. #warning CMSE is 3
    7. #endif

    ES output when rebuilding the project:

    Source Code

    1. Rebuilding ‘ses_build_time’ from solution ‘ses_build_time’ in configuration ‘Debug’
    2. 3> Compiling ‘main.c’
    3. 5> Assembling ‘Cortex_M_Startup.s’
    4. 6> Assembling ‘SEGGER_THUMB_Startup.s’
    5. 3> /Users/ti102724/work/ses_build_time/Source/main.c:32:4: warning: CMSE is 3 [-W#warnings]
    6. 3> #warning CMSE is 3
    7. 3> ^
    8. 3> 1 warning generated.
    9. 3> Analyzing main.c
    10. 3> 1 warning generated.
    11. 3> /Users/ti102724/work/ses_build_time/Source/main.c:30:4: warning: CMSE is 1 [clang-diagnostic-#warnings]
    12. 3> #warning CMSE is 1
    13. 3> ^
    14. 7> Linking ses_build_time.elf
    15. Build complete
    Display All
    This makes the code analyser fail when compiling our projects that use this CMSIS header: github.com/ARM-software/CMSIS_…e/Include/core_armv8mml.h

    Note that when "v8M Has CMSE Instructions" is set to No, both the stages report value of 1 which makes me believe that the option might be not passed to the code analyzer.

    To reproduce: open the attached project, rebuild it.
    Embedded Studio version: 6.40
    Files
  • Hello,

    Thank you for your inquiry.
    The reported behaviour is reproducible.
    Indeed only some preprocessor options are passed to the analyzer. You can see the CL call in the output window if you enable "Echo Build Command Lines".

    I will check with the team if this is intended behaviour.

    As a workaround you can set a custom analyzer CL in project options via Code > Code Analyzer > Analyze Command

    EDIT: It is not intended behaviour and will be fixed with the next ES release.
    To get notified automatically when the release launches you can subscribe here:
    segger.com/notification/subscribe.php?prodid=196

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.