AUTOSAR C++14 Rule A0-1-3
Every function defined in an anonymous namespace, or static function with internal linkage, or private member function shall be used
Since R2020b
Description
Rule Definition
Every function defined in an anonymous namespace, or static function with internal linkage, or private member function shall be used.
Rationale
Functions defined in an anonymous namespace and static functions with internal linkage are callable only inside the compilation unit in which they are defined. Similarly, private member functions are callable only inside the class implementation that they belong to. In both these cases, such functions are intended to be used exclusively in the current source code and not in external code that is integrated later on into the project. Not using such functions indicates poor software design or missing logic in the current code base.
Note
An explicit function call in the source code is sufficient to satisfy this rule, even if the call is not reachable at run time. A separate rule, M0-1-1, checks for all unreachable code occurrences.
Polyspace Implementation
If a function defined in your source code is not called explicitly and belongs to one of these categories, the checker flags the function definition:
Functions defined in anonymous namespace
Static functions with internal linkage
Private member functions that are defined outside the class definition
The checker does not flag an uncalled private member function that is defined inside the class definition.
The checker does not flag private member functions that are defined outside the class definition in a default Polyspace® as You Code analysis. See Checkers Deactivated in Polyspace as You Code Analysis (Polyspace Access).
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Language independent issues |
Category: Required, Automated |
Version History
Introduced in R2020b