[Ada] Cleanup repeated code for aggregate constraints checks
Code cleanup related to examining uses of Check_Unset_Reference for improved detection of uninitialised scalar objects. Semantics is unaffected. gcc/ada/ * sem_util.adb (Aggregate_Constraint_Checks): Fix whitespace; refactor repeated code; replace a ??? comment with an explanation based on the comment for the routine spec.
This commit is contained in:
parent
074e8addc5
commit
dd1c3433aa
@ -1153,7 +1153,7 @@ package body Sem_Util is
|
||||
(Exp : Node_Id;
|
||||
Check_Typ : Entity_Id)
|
||||
is
|
||||
Exp_Typ : constant Entity_Id := Etype (Exp);
|
||||
Exp_Typ : constant Entity_Id := Etype (Exp);
|
||||
|
||||
begin
|
||||
if Raises_Constraint_Error (Exp) then
|
||||
@ -1236,12 +1236,12 @@ package body Sem_Util is
|
||||
and then Is_Scalar_Type (Check_Typ)
|
||||
and then Exp_Typ /= Check_Typ
|
||||
then
|
||||
-- If expression is a constant, it is worthwhile checking whether it
|
||||
-- is a bound of the type.
|
||||
|
||||
if Is_Entity_Name (Exp)
|
||||
and then Ekind (Entity (Exp)) = E_Constant
|
||||
then
|
||||
-- If expression is a constant, it is worthwhile checking whether
|
||||
-- it is a bound of the type.
|
||||
|
||||
if (Is_Entity_Name (Type_Low_Bound (Check_Typ))
|
||||
and then Entity (Exp) = Entity (Type_Low_Bound (Check_Typ)))
|
||||
or else
|
||||
@ -1249,21 +1249,16 @@ package body Sem_Util is
|
||||
and then Entity (Exp) = Entity (Type_High_Bound (Check_Typ)))
|
||||
then
|
||||
return;
|
||||
|
||||
else
|
||||
Rewrite (Exp, Convert_To (Check_Typ, Relocate_Node (Exp)));
|
||||
Analyze_And_Resolve (Exp, Check_Typ);
|
||||
Check_Unset_Reference (Exp);
|
||||
end if;
|
||||
|
||||
-- Could use a comment on this case ???
|
||||
|
||||
else
|
||||
Rewrite (Exp, Convert_To (Check_Typ, Relocate_Node (Exp)));
|
||||
Analyze_And_Resolve (Exp, Check_Typ);
|
||||
Check_Unset_Reference (Exp);
|
||||
end if;
|
||||
|
||||
-- Change Exp into Check_Typ'(Exp) to ensure that range checks are
|
||||
-- performed at run time.
|
||||
|
||||
Rewrite (Exp, Convert_To (Check_Typ, Relocate_Node (Exp)));
|
||||
Analyze_And_Resolve (Exp, Check_Typ);
|
||||
Check_Unset_Reference (Exp);
|
||||
|
||||
end if;
|
||||
end Aggregate_Constraint_Checks;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user