Crep := False;
end if;
+ -- If the actual denotes a variable which captures the value of an
+ -- object for validation purposes, we propagate the link with this
+ -- object to the new variable made from the actual just above.
+
+ if Ekind (Formal) /= E_In_Parameter
+ and then Is_Validation_Variable_Reference (Actual)
+ then
+ declare
+ Ref : constant Node_Id := Unqual_Conv (Actual);
+
+ begin
+ if Is_Entity_Name (Ref) then
+ Set_Validated_Object (Var, Validated_Object (Entity (Ref)));
+
+ else
+ pragma Assert (False);
+ null;
+ end if;
+ end;
+ end if;
+
-- Setup initialization for case of in out parameter, or an out
-- parameter where the formal is an unconstrained array (in the
-- latter case, we have to pass in an object with bounds).
Name => Lhs,
Expression => Expr));
end if;
+
+ -- Add a copy-back to reflect any potential changes in value
+ -- back into the original object, if any.
+
+ if Is_Validation_Variable_Reference (Lhs) then
+ Add_Validation_Call_By_Copy_Code (Lhs);
+ end if;
end;
end if;
end Add_Call_By_Copy_Code;
--------------------------------------
procedure Add_Validation_Call_By_Copy_Code (Act : Node_Id) is
+ Var : constant Node_Id := Unqual_Conv (Act);
+
Expr : Node_Id;
Obj : Node_Id;
Obj_Typ : Entity_Id;
- Var : constant Node_Id := Unqual_Conv (Act);
Var_Id : Entity_Id;
begin
end if;
end if;
- -- The actual denotes a variable which captures the value of an
- -- object for validation purposes. Add a copy-back to reflect any
- -- potential changes in value back into the original object.
-
- -- Var : ... := Object;
- -- if not Var'Valid then -- validity check
- -- Call (Var); -- modify var
- -- Object := Var; -- update Object
-
- -- This case is given higher priority because the subsequent check
- -- for type conversion may add an extra copy of the variable and
- -- prevent proper value propagation back in the original object.
-
- if Is_Validation_Variable_Reference (Actual) then
- Add_Validation_Call_By_Copy_Code (Actual);
-
-- If argument is a type conversion for a type that is passed by
-- copy, then we must pass the parameter by copy.
- elsif Nkind (Actual) = N_Type_Conversion
+ if Nkind (Actual) = N_Type_Conversion
and then
(Is_Elementary_Type (E_Formal)
or else Is_Bit_Packed_Array (Etype (Formal))
and then not In_Subrange_Of (E_Actual, E_Formal)))
then
Add_Call_By_Copy_Code;
+
+ -- The actual denotes a variable which captures the value of an
+ -- object for validation purposes. Add a copy-back to reflect any
+ -- potential changes in value back into the original object.
+
+ -- Var : ... := Object;
+ -- if not Var'Valid then -- validity check
+ -- Call (Var); -- modify var
+ -- Object := Var; -- update Object
+
+ elsif Is_Validation_Variable_Reference (Actual) then
+ Add_Validation_Call_By_Copy_Code (Actual);
end if;
-- RM 3.2.4 (23/3): A predicate is checked on in-out and out