メインコンテンツ

AUTOSAR C++14 Rule M3-9-1

The types used for an object, a function return type, or a function parameter shall be token-for-token identical in all declarations and re-declarations.

説明

ルール定義

The types used for an object, a function return type, or a function parameter shall be token-for-token identical in all declarations and re-declarations.

根拠

再宣言が前の宣言とトークン単位で同一でない場合、再宣言されているオブジェクトまたは関数が目視検査では不明確になります。

Polyspace 実装

ルール チェッカーは、現在の宣言とその前に確認された宣言を比較します。

トラブルシューティング

ルール違反が想定されるものの、Polyspace® から報告されない場合は、コーディング規約違反が想定どおりに表示されない理由の診断を参照してください。

すべて展開する

typedef int* intptr;

int* map;
extern intptr map; //Noncompliant

intptr table;
extern intptr table; //Compliant

この例では、変数 map が 2 回宣言されています。2 番目の宣言では、最初の宣言の型に解決される typedef が使用されています。typedef が原因で、2 番目の宣言は最初の宣言とトークン単位で同一ではありません。

チェック情報

グループ: 基本概念
カテゴリ: Required、Automated

バージョン履歴

R2019a で導入