C-STAT directives in comments
Syntax
//cstatop[opop...] /*cstatop[opop...]*/
Parameters
is one of:op
| Disables the specified C-STAT check until the end of the compilation unit or until a matching |
| Re-enables the specified C-STAT check until the end of the compilation unit or until a matching |
| Disables the specified C-STAT check for a single line. If the line of the specified directive consists of more than just the comment, the line where the directive is placed is used for disabling the specified C-STAT check. Otherwise, the next line that consists of more than just a comment is used. |
| If placed inside a function body, disables the specified C-STAT check from that line, until the end of the function. If placed outside a function body, disables the specified C-STAT check for the immediately following function. |
|
|
Note that you can use the wildcard (*) character to match multiple tags and thus disable multiple checks.
You can supply a comment/justification for disabling the check by adding a colon : after the suppression statement. Any text from there will be inserted in the report as User comment. In C-style comments, everything between the : and the */ is part of the justification. More lines can be added by starting consecutive comments with cstat :. Note that the space before the colon is mandatory.
Description
Use the comment characters (and the operators) to disable or enable C-STAT messages for specific checks.
Example
//cstat -MISRAC2004* -MISRAC2012-Rule-4.2 // ... // Messages about MISRA C 2012 rule 4.2 and the whole MISRA C // 2004 package suppressed here // ... //cstat +MISRAC2004* +MISRAC2012-Rule-4.2 // ... // Messages about MISRA C 2012 rule 4.2 and the whole MISRA C // 2004 package unsuppressed here // ... //cstat !MISRAC2004-6.3 int a;
or
int a; //cstat !MISRAC2004-6.3
will disable the message given by MISRA C 2004 6.3 regarding the int a; statement.
//cstat #ARR-inv-index
void f(...)
{
...// Messages about ARR-inv-index suppressed here
}
void f() {
...
//cstat #ARR-inv-index
// Messages about ARR-inv-index suppressed here
} // ARR-inv-index reenabled here
Supplying a user comment/justification for disabling a check, C-style:
/*cstat !RED-unused-enum-val (this is not part of output) : This will be in the report, the text continues until */
Supplying a user comment/justification for disabling a check, C++-style:
//cstat !RED-unused-enum-val : We can have //cstat :more lines of text //cstat :like this // Any other comment will only be in the code. // It can be used to suppress a suppression, typically temporary. //cstat : !RED-unused-enum-val // For now we do not suppress here as the line starts with `:`.