
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
72 lines
1.8 KiB
Plaintext
72 lines
1.8 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,cpp]
|
|
----
|
|
void doSomething() {
|
|
; // Noncompliant - was used as a kind of TODO marker
|
|
}
|
|
|
|
#define A(x) x; // Noncompliant - macro definitions should not end with a semi-colon when they are used as functions
|
|
|
|
void fun() {
|
|
A(5); // Noncompliant - after expansion, there are 2 consecutive semi-colons
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,cpp]
|
|
----
|
|
void doSomething() {
|
|
}
|
|
|
|
#define A(x) x
|
|
|
|
void fun() {
|
|
A(5);
|
|
}
|
|
----
|
|
|
|
=== Exceptions
|
|
|
|
In the case of an empty expanded macro, the issue is not raised.
|
|
|
|
Example:
|
|
|
|
[source,cpp]
|
|
----
|
|
#define LOG(x)
|
|
|
|
void fun() {
|
|
LOG(X);
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
* MISRA C:2004, 14.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.
|
|
* MISRA {cpp}:2008, 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.
|
|
* https://wiki.sei.cmu.edu/confluence/x/5dUxBQ[CERT, MSC12-C.] - Detect and remove code that has no effect or is never executed
|
|
* https://wiki.sei.cmu.edu/confluence/x/IDZGBQ[CERT, MSC51-J.] - Do not place a semicolon immediately following an if, for, or while condition
|
|
* https://wiki.sei.cmu.edu/confluence/x/WtYxBQ[CERT, EXP15-C.] - Do not place a semicolon on the same line as an if, for, or while statement
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|