Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

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

SLT
SLT Posts: 9

Hi,
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?

Thanks.

Comments

  • SLT
    SLT Posts: 9

    The rule is not listed.

  • mzwawa
    mzwawa Posts: 21

    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.

  • SLT
    SLT 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!

  • mzwawa
    mzwawa Posts: 21

    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').

  • SLT
    SLT Posts: 9

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