From 04920bb67f9d7014248beed823a6a4ac50dbedd4 Mon Sep 17 00:00:00 2001 From: Javier Miranda Date: Mon, 28 May 2018 08:55:42 +0000 Subject: [PATCH] [Ada] Fix regression of ACATS c46032a with CCG back end 2018-05-28 Javier Miranda gcc/ada/ * 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. From-SVN: r260837 --- gcc/ada/ChangeLog | 8 ++++++++ gcc/ada/exp_ch4.adb | 24 ++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 19cb29682eb..c00a76df1c8 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2018-05-28 Javier Miranda + + * 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 * sem_util.adb (Is_OK_Volatile_Context): Add attributes First, Last and diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 508123dd13b..517a8da65bd 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -11096,8 +11096,10 @@ package body Exp_Ch4 is -- 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 @@ -11112,15 +11114,29 @@ package body Exp_Ch4 is 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)); @@ -11132,7 +11148,7 @@ package body Exp_Ch4 is 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 -- 2.30.2