C and C++


LANG.STRUCT.DECL.IMPFN : Implicit Function Declaration

Summary

A function is invoked, but it has not yet been declared.

Properties

Class Name Implicit Function Declaration
Significance style
Mnemonic LANG.STRUCT.DECL.IMPFN
Categories
MisraC2023 MisraC2023:17.3 A function shall not be declared implicitly
Misra2012 Misra2012:17.3 A function shall not be declared implicitly
Misra2004 Misra2004:8.1 Functions shall have prototype declarations and the prototype shall be visible at both the function definition and call
AUTOSARC++14 AUTOSARC++14:A1-1-1 All code shall conform to ISO/IEC 14882:2014 - Programming Language C++ and shall not use deprecated features.
MisraC++2023 MisraC++2023:4.1.2 Deprecated features should not be used
CWE CWE:686 Function Call With Incorrect Argument Type
CERT-C CERT-C:MSC23-C Beware of vendor-specific library and language differences
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default, and require the unnormalized C ASTs for the project. To enable them, add the following WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Implicit Function Declaration"
Note that retaining the unnormalized ASTs will increase the disk space used to store the project representation, and may make the analysis take longer.

Example

int f(double a);   
 
int lang_struct_decl_impfn_before(double a){
    return f(a);                                          /* f() already declared */             
}
 
int lang_struct_decl_impfn_none(double a){
    return g(a);                 /* 'Implicit Function Declaration' warning issued here
                                  * - g() never declared */
}
 
int lang_struct_decl_impfn_after(double a){
  return h(a);                   /* 'Implicit Function Declaration' warning issued here
                                  * - h() declared after invocation */
}

int h(double a);

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.