C and C++


LANG.STRUCT.FNADDR : 暗黙の関数アドレス使用

要旨

& 演算子を使用せず)暗黙的に関数のアドレスを使用しています。

プロパティ

クラス名 Implicit Address of Function
日本語クラス名 暗黙の関数アドレス使用
クラス分類 スタイル (style)
ニーモニック LANG.STRUCT.FNADDR
カテゴリー
MisraC2023 MisraC2023:17.12 A function identifier should only be used with either a preceding &, or with a parenthesized parameter list
Misra2012 Misra2012:17.12 A function identifier should only be used with either a preceding &, or with a parenthesized parameter list
Misra2004 Misra2004:16.9 A function identifier shall only be used with either a preceding &, or with a parenthesised parameter list, which may be empty
AUTOSARC++14 AUTOSARC++14:M8-4-4 A function identifier shall either be used to call the function or it shall be preceded by &.
MisraC++2008 MisraC++2008:8-4-4 A function identifier shall either be used to call the function or it shall be preceded by &.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっており、プロジェクトには非正規の C向けAST が必要になります。有効にするにはプロジェクト設定ファイル (configuration file) に以下の WARNING_FILTER ルールと RETAIN_UNNORMALIZED_C_AST 設定を追加してください。
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Implicit Address of Function"
注:非正規化された AST を継続して使用した場合、使用ディスク容量が増加し解析時間が長くなる可能性があります。

typedef void (*ftype)(void);
void callfn(ftype fin);
void f(void);

int lang_struct_fnaddr(void){
    int rv = 0;
    if (f) {rv = 1;}   /* 'Implicit Address of Function' warning issued here */
    f;                 /* 'Implicit Address of Function' warning issued here */
    callfn(f);         /* 'Implicit Address of Function' warning issued here */

    f();                                                      /* normal function call */
    callfn(&f);                                               /* explicit addressing */
    return rv;
}

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

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