AutosarC++17_10-A2.11.2

A “using” name shall be a unique identifier within a namespace

Required inputs: IR

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 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#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 n1
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