AUTOSAR C++14 Rule M15-3-6
Where multiple handlers are provided in a single try-catch statement or function-try-block for a derived class and some or all of its bases, the handlers shall be ordered most-derived to base class.
説明
ルール定義
Where multiple handlers are provided in a single try-catch statement or function-try-block for a derived class and some or all of its bases, the handlers shall be ordered most-derived to base class.
根拠
try-catch または function-try ブロックでは、派生クラスの例外オブジェクトが、基底クラスを受け入れるハンドラー catch ブロックに一致します。基底例外クラスのハンドラーを派生例外クラスのハンドラーの前に配置すると、基底クラス ハンドラーが基底クラス例外と派生クラス例外の両方を処理します。派生クラス ハンドラーは到達不能コードになり、予期せぬ動作となります。クラス階層を使用して例外を発生させるときは、必ず派生クラスのハンドラーが基底クラスのハンドラーに先行するようにします。
Polyspace 実装
ハンドラー ブロックが基底クラスのハンドラーより後にある場合、Polyspace® はそのハンドラー ブロックにフラグを設定します。
トラブルシューティング
ルール違反が想定されるものの、Polyspace から報告されない場合は、コーディング規約違反が想定どおりに表示されない理由の診断を参照してください。
例
チェック情報
| グループ: Exception Handling |
| カテゴリ: Required、Automated |
バージョン履歴
R2019a で導入