AUTOSAR C++14 Rule A2-10-6
A class or enumeration name shall not be hidden by a variable, function or enumerator declaration in the same scope
Since R2020a
Description
Rule Definition
A class or enumeration name shall not be hidden by a variable, function or enumerator declaration in the same scope.
Rationale
When a variable, data member, function, or enumerator shares its name with a class or enumeration in the same scope, the latter is hidden. That is, all uses of the name refers to the variable, data member, function, or enumerator instead of the class or enumeration, regardless of declaration order. Hidden classes or enumerations can be misleading and can lead to compilation errors. Do not re-use names to declare classes and enumerations.
Polyspace Implementation
Polyspace® flags the declaration of a variable, data member, function, or enumerator that shares the name of a class or enumeration in the same block.
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: Lexical conventions |
Category: Required, Automated |
Version History
Introduced in R2020a