Skip to content

Commit

Permalink
Modify rule S3471: add diff view
Browse files Browse the repository at this point in the history
  • Loading branch information
amelie-renard-sonarsource committed Oct 12, 2023
1 parent 9327e7c commit 5108b75
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rules/S3471/cfamily/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
== Why is this an issue?

In a base class, ``++virtual++`` indicates that a function can be overridden. In a derived class, it indicates an override. But given the specifier's dual meaning, it would be both clearer and more sound to use derived class-specific specifiers instead: ``++override++`` or ``++final++``.
In a base class, ``++virtual++`` indicates that a function can be overridden. In a derived class, it indicates an override. But given the specifier's dual meaning, it would be clearer and more sound to use derived class-specific specifiers instead: ``++override++`` or ``++final++``.

[source,cpp]
----
Expand All @@ -12,7 +12,10 @@ public:
c++;
}
};
----

[source,cpp,diff-id=1,diff-type=noncompliant]
----
class FastCounter: public Counter {
public:
virtual void count() { // Noncompliant: ambiguous
Expand All @@ -24,7 +27,7 @@ public:
* ``++override++`` indicates that a function is intended to override a base-class function. The compiler will issue a warning if this is not the case.
[source,cpp]
[source,cpp,diff-id=1,diff-type=compliant]
----
class FastCounter: public Counter {
public:
Expand All @@ -36,7 +39,7 @@ public:

* ``++final++`` indicates a function ``++override++`` that cannot itself be overridden. The compiler will issue a warning if the signature does not match the signature of a base-class ``++virtual++`` function. `override` is redundant when `final` is specified.
[source,cpp]
[source,cpp,diff-id=1,diff-type=compliant]
----
class FastCounter: public Counter {
public:
Expand Down Expand Up @@ -86,7 +89,7 @@ specifier to be dropped
\[~evgeny.mandrikov] given the fact that it's only a compiler warning to have a ``++virtual++`` function in a derived class with a mismatched signature, do we want a rule on that?


E.G.
E.G.

----
class BaseClass
Expand Down

0 comments on commit 5108b75

Please sign in to comment.