MISRAC2004-14.3
Synopsis
(Required) 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 whitespace character.
Enabled by default
Yes
Severity/Certainty
Low/Low

Full description
There are stray semicolons on the same line as other code. This check is identical to EXP-stray-semicolon, MISRAC++2008-6-2-3.
Coding standards
- CERT EXP15-C
Do not place a semicolon on the same line as an if, for, or while statement
- MISRA C:2004 14.3
(Required) 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 whitespace character.
- MISRA C++ 2008 6-2-3
(Required) 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.
Code examples
The following code example fails the check and will give a warning:
void example(void) {
int i;
for (i=0; i!=10; ++i); //Null statement as the
//body of this for loop
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
int i;
for (i=0; i!=10; ++i){ //An empty block is much
} //more readable
}