AutosarC++18_10-A2.10.1¶
An identifier declared in an inner scope shall not hide an identifier declared in an outer scope
Required inputs: IR
Bad code
int foo(int i) {
int i = 0; // Non-Compliant - variable hides parameter
return i;
}
Bad code (distinguish_name_spaces disabled)
class C {
int i; // field
C(int i) { this->i = i; } // Compliant in constructor
void f(int i) { this->i = i; } // Non-Compliant - parameter hides field
};
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
hiding |
{} hides {} |
None |
False |
Options¶
This rule shares the following common options: 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_hiding_if_condition_in_else¶
allow_hiding_if_condition_in_else : bool = False
if (auto x = get(1); x.ok()) {}
else if (auto x = get(2); x.ok()) {}
This option causes the rule to act as if variables declared in the
if condition were only visible in the then-branch.
allow_in_classes¶
allow_in_classes : bool = True
allow_in_lambdas¶
allow_in_lambdas : bool = True
allow_in_namespaces¶
allow_in_namespaces : bool = True
allow_parameter_in_function_declaration¶
allow_parameter_in_function_declaration : bool = False
check_inheritance_hiding¶
check_inheritance_hiding : bool = False
check_nested_classes¶
check_nested_classes : bool = False
constructor_parameters_not_hiding_fields_in_initializer_list¶
constructor_parameters_not_hiding_fields_in_initializer_list : bool = False
distinguish_name_spaces¶
distinguish_name_spaces : bool = False
hiding_entities¶
hiding_entities : set[bauhaus.ir.LIR_Class_Name] = {'Field', 'Parameter', 'Typedef_Type', 'Variable'}
maxlen¶
maxlen : int | None = None
tolerate_constructor_parameters_hiding_fields¶
tolerate_constructor_parameters_hiding_fields : bool = False
tolerate_function_prototype_argument_hiding¶
tolerate_function_prototype_argument_hiding : bool = False
decltype()).
tolerate_hiding_private_members¶
tolerate_hiding_private_members : bool = False
tolerate_macro_local_identifier¶
tolerate_macro_local_identifier : bool = False