+2018-05-28 Javier Miranda <miranda@adacore.com>
+
+ * exp_ch4.adb (Real_Range_Check): Add a temporary to store the integer
+ value when converting a float value to a fixed-point value. This is
+ required for CCG because it handles fixed-point types by means of
+ unsigned integer type variables. The range check is now performed using
+ the integer value stored in this temporary.
+
2018-05-28 Yannick Moy <moy@adacore.com>
* sem_util.adb (Is_OK_Volatile_Context): Add attributes First, Last and
-- conversion to the target fixed-point type.
declare
- Int_Type : Entity_Id;
Bfx_Type : constant Entity_Id := Base_Type (Target_Type);
+ Expr_Id : constant Entity_Id :=
+ Make_Temporary (Loc, 'T', Conv);
+ Int_Type : Entity_Id;
begin
if RM_Size (Bfx_Type) > RM_Size (Standard_Integer) then
Int_Type := Standard_Short_Integer;
end if;
+ -- Generate a temporary with the integer value. Required in the
+ -- CCG compiler to ensure that runtime checks reference this
+ -- integer expression (instead of the resulting fixed-point
+ -- value) because fixed-point values are handled by means of
+ -- unsigned integer types).
+
+ Insert_Action (N,
+ Make_Object_Declaration (Loc,
+ Defining_Identifier => Expr_Id,
+ Object_Definition => New_Occurrence_Of (Int_Type, Loc),
+ Constant_Present => True,
+ Expression =>
+ Convert_To (Int_Type, Expression (Conv))));
+
-- Create integer objects for range checking of result.
Lo_Arg := Unchecked_Convert_To (Int_Type,
- New_Occurrence_Of (Tnn, Loc));
+ New_Occurrence_Of (Expr_Id, Loc));
Lo_Val := Make_Integer_Literal (Loc,
Corresponding_Integer_Value (Lo));
Hi_Arg := Unchecked_Convert_To (Int_Type,
- New_Occurrence_Of (Tnn, Loc));
+ New_Occurrence_Of (Expr_Id, Loc));
Hi_Val := Make_Integer_Literal (Loc,
Corresponding_Integer_Value (Hi));
Subtype_Mark =>
New_Occurrence_Of (Target_Type, Loc),
Expression =>
- Convert_To (Int_Type, Expression (Conv)));
+ New_Occurrence_Of (Expr_Id, Loc));
end;
else -- For all other conversions