MISRA C++:2008 Rule 6-2-3
Before preprocessing, a null statement shall only occur on a line by itself; it may be followed by a comment, provided that the first character following the null statement is a white-space character
Description
Rule Definition
Before preprocessing, a null statement shall only occur on a line by itself; it may be followed by a comment, provided that the first character following the null statement is a white-space character.
Rationale
A null statement:
;
A comment can follow a null statement, but use a white space character between the null statement and the comment to provide a visual cue for reviewers.
Polyspace Implementation
The rule checker considers a null statement as a line where the first character excluding comments is a semicolon. The rule checker reports violations for situations where:
Comments appear before the null statement.
For instance:
/* wait for pin */ ;
Comments appear immediately after the semicolon without a white space in between.
For instance:
;// wait for pin
The rule checker also reports a violation when a second statement appears on the same line following the null statement.
For instance:
; count++;
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Statements |
Category: Required |
Version History
Introduced in R2013b