C and C++


LANG.STRUCT.DECL.IMPT : Implicit Type

Summary

A type is not explicitly specified in one of the following contexts.

When type is not explicitly specified in these cases, it is implicitly int. This may not be what the writer intended, or what a reader assumes.

Properties

Class Name Implicit Type
Significance style
Mnemonic LANG.STRUCT.DECL.IMPT
Categories
MisraC2023 MisraC2023:8.1 Types shall be explicitly specified
Misra2012 Misra2012:8.1 Types shall be explicitly specified
Misra2004 Misra2004:8.2 Whenever an object or function is declared or defined, its type shall be explicitly stated
CERT-C CERT-C:DCL07-C Include the appropriate type information in function declarators
Availability Available for C only (not C++).
Enabling Checks for this warning class are disabled by default. To enable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Implicit Type"

Example

f1();              /* 'Implicit Type' warning issued here
                    * - return type implicitly int
                    */
int f2();                           /* ok: explicit return type */

g1(){              /* 'Implicit Type' warning issued here
                    * - return type implicitly int
                    */
    return 42;
}

int g2(){                           /* ok: explicit return type */
    return 42;
}

int h1(const x);   /* 'Implicit Type' warning issued here
                    * - parameter type implicitly const int
                    */
int h2(const int x);                /* ok: explicit parameter type */

a_global1 = 42;    /* 'Implicit Type' warning issued here
                    * - variable type implicitly int
                    */
int a_global2 = 42;                 /* ok: explicit variable type */

extern an_extern1; /* 'Implicit Type' warning issued here
                    * - variable type implicitly int
                    */
extern int an_extern2;              /* ok: explicit variable type */

Relevant Configuration File Parameters

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