"Comments shall not be nested." Custom Rule in Static Analysis

SLTSLT Posts: 9

I have to add this rule to perform a static analysis.
The rule is the MISRA C RULE 9.
"Comments shall not be nested".

Can someone help me?



  • SLTSLT Posts: 9

    The rule is not listed.

  • mzwawamzwawa Posts: 20

    Hi SLT,
    there are already some existing rules in C/C++test, which check if there are nested comments in C/C++ code. Please, look in C/C++test at the rules like COMMENT-11, COMMENT-12, MISRA2004-2_3 or MISRA2012-RULE-3_1. They should help you.

  • SLTSLT Posts: 9

    @mzwawa Thank you so much!
    Since you've been so kind, I'd ask you for help with this rule too:
    "Switch statements shall not be nested".
    Maybe this rule is also listed but I just can't find it!

  • mzwawamzwawa Posts: 20

    Unfortunately, I cannot find this rule in C/C++test. However, there is a similar rule MISRA2004-15_1 ('A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement').

  • SLTSLT Posts: 9

    @mzwawa Yes!!!! :) Thank you so much!

Sign In or Register to comment.