rspec/rules/S1012/cfamily/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

49 lines
1.3 KiB
Plaintext

== Why is this an issue?
The use of ``++virtual++`` base classes can introduce a number of undefined and potentially confusing behaviours. Therefore, a base class shall only be declared ``++virtual++`` if that base class is to be used as a common base class in a diamond hierarchy.
=== Noncompliant code example
[source,cpp]
----
class A {};
class B1: public virtual A {}; // Compliant, A is a common base for C
class B2: public virtual A {}; // Compliant, A is a common base for C
class C: public B1, B2 {};
class D: public virtual A {}; // Noncompliant, D is not part of a diamond-shaped hierarchy.
----
== Resources
* MISRA {cpp}:2008, 10-1-2 - A base class shall only be declared virtual if it is used in a diamond hierarchy.
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove the "virtual" specifier on class "xxx".
'''
== Comments And Links
(visible only on this page)
=== on 16 Oct 2014, 13:21:54 Ann Campbell wrote:
\[~samuel.mercier] please:
* fill in the appropriate reference field(s).
* provide a See section.
* use double curly braces around code in the description
* use the standard section titles
Also, since the description references undefined behavior, I wouldn't tie this to Maintainability, but Reliability instead.
endif::env-github,rspecator-view[]