AutosarC++17_03-A2.11.2¶
A “using” name shall be a unique identifier within a namespace
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
Reusing a using name either as another using name or for any other purpose may lead to developer confusion. The same using shall not be duplicated anywhere within a namespace.
Example
//% $Id: A2-11-2.cpp 271715 2017-03-23 10:13:51Z piotr.tanski $
#include <cstdint>
namespace n1 {
using func = void (*)(std::int32_t, std::int32_t);
void f1() {
using func = void (*)(void); // Non-compliant, reuses func identifier declared
// in the same namespace
}
}
namespace n2 {
using func = void (*)(std::int32_t,
std::int32_t); // Compliant, reuses func identifier but
// in another namespace
}
See Also
- MISRA C++ 2008 [6]: Rule 2-10-3 (Required) A typedef name (including qualification, if any) shall be a unique identifier.
- JSF December 2005 [7]: 4.15 AV Rule 135 Identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide that identifier.
- HIC++ v4.0 [8]: 2.4.1 Ensure that each identifier is distinct from any other visible identifier
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
reused_using |
Using name reused. |
None |
False |
Options
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
This rule has no individual options.