AutosarC++18_10-A2.10.4¶
The identifier name of a non-member object with static storage duration or static function shall not be reused within a namespace
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
No identifier with static storage duration should be re-used in the same namespace across any source files in the project.
This may lead to the developer or development tool confusing the identifier with another one.
Example
//% $Id: A2-10-4.cpp 305382 2018-01-26 06:32:15Z michal.szczepankiewicz $
#include <cstdint>
// f1.cpp
namespace ns1
{
static std::int32_t globalvariable = 0;
}
// f2.cpp
namespace ns1
{
// static std::int32_t globalvariable = 0; // Non-compliant - identifier reused
// in ns1 namespace in f1.cpp
}
namespace ns2
{
static std::int32_t globalvariable =
0; // Compliant - identifier reused, but in another namespace
}
// f3.cpp
static std::int32_t globalvariable =
0; // Compliant - identifier reused, but in another namespace
See Also
- MISRA C++ 2008 [7]: advisory 2-10-5 The identifier name of a non-member object or function with static storage duration should not be reused.
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
reused_global_function_name |
Name of object or function with static storage duration reused. |
None |
False |
reused_global_variable_name |
Name of object or function with static storage duration 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
allow_overloads¶
allow_overloads : bool = True
allow_reusing_function_name_for_locals¶
allow_reusing_function_name_for_locals : bool = False
allow_static_no_linkage¶
allow_static_no_linkage : bool = False
detect_different_compilation_units_overloads¶
detect_different_compilation_units_overloads : bool = False
func_filter¶
func_filter : typing.Callable[[bauhaus.ir.Node], bool] | None = None
include_local_variables¶
include_local_variables : bool = False
use_unqualified_names¶
use_unqualified_names : bool = False
var_filter¶
var_filter : typing.Callable[[Variable], bool] | None = None