diff options
author | Javier Miranda <miranda@adacore.com> | 2018-05-28 08:55:42 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-05-28 08:55:42 +0000 |
commit | 04920bb67f9d7014248beed823a6a4ac50dbedd4 (patch) | |
tree | 10ab30d2d05f7663463c759120b58cdcc8779705 | |
parent | cb1a067201dec2585968531ee1a03363bf9210f5 (diff) | |
download | gcc-04920bb67f9d7014248beed823a6a4ac50dbedd4.zip gcc-04920bb67f9d7014248beed823a6a4ac50dbedd4.tar.gz gcc-04920bb67f9d7014248beed823a6a4ac50dbedd4.tar.bz2 |
[Ada] Fix regression of ACATS c46032a with CCG back end
2018-05-28 Javier Miranda <miranda@adacore.com>
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
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/exp_ch4.adb | 24 |
2 files changed, 28 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 19cb296..c00a76d 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +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 diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 508123d..517a8da 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 |