MISRA C++:2008 Rule 0-1-5
A project shall not contain unused type declarations
Description
Rule Definition
A project shall not contain unused type declarations.1
Rationale
If you declare a type but do not use it, determining if the type is redundant or left unused by mistake is difficult when you review your code.
For example, if you declare an enumerated data type to store some specialized data, but then use an integer type to store the data, the unused type can indicate a coding error.
Polyspace Implementation
Polyspace® reports a violation of this rule if your code contains unused local types.
As an exception, Polyspace does not report a violation if you define the unused type with
public
access in a template class.
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 |
Version History
Introduced in R2018a1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.