C and C++


LANG.TYPE.IISVB : Implicit Inheritance from Stateful Virtual Base

要旨

A class is derived from a virtual stateful base class through indirect inheritance only.

We say a class is stateful if it has at least one data member.

This class is a strict subset of Virtual Base Class.

プロパティ

クラス名 Implicit Inheritance from Stateful Virtual Base
日本語クラス名 Implicit Inheritance from Stateful Virtual Base
クラス分類 スタイル (style)
ニーモニック LANG.TYPE.IISVB
カテゴリー
AUTOSARC++14 AUTOSARC++14:M10-1-1 Classes should not be derived from virtual bases.
MisraC++2008 MisraC++2008:10-1-1 Classes should not be derived from virtual bases.
MisraC++2023 MisraC++2023:13.1.1 Classes should not be inherited virtually
JSF++ JSF++:88.1 A stateful virtual base shall be explicitly declared in each derived class that accesses it.
対応言語 C++ のみ利用可能です。 C は利用できません。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっており、プロジェクトには非正規の C向けAST が必要になります。有効にするにはプロジェクト設定ファイル (configuration file) に以下の WARNING_FILTER ルールと RETAIN_UNNORMALIZED_C_AST 設定を追加してください。
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Implicit Inheritance from Stateful Virtual Base"
注:非正規化された AST を継続して使用した場合、使用ディスク容量が増加し解析時間が長くなる可能性があります。

struct A { int a; };                          // A has a data member so is considered "stateful".

struct B : virtual A {};
struct C : virtual A {};

struct D : B {}; // 'Implicit Inheritance from Stateful Virtual Base' warning issued here
                 // - inherits 'virtual A' indirectly only

struct E: C, virtual A {};                     // ok: inherits 'virtual A' directly (and indirectly)

struct F : D, E {}; // 'Implicit Inheritance from Stateful Virtual Base' warning issued here
                    // - inherits 'virtual A' indirectly but not directly

struct G : D, E, virtual A {};                // ok: inherits 'virtual A' directly (and indirectly)

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。