aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2019-12-31 08:28:35 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-02 04:58:28 -0400
commit646204de717040064c18c189e29a32d0d33fd08b (patch)
tree679697ed32fe7307594f52aaa620839abad5e9f0 /gcc
parent4b490c1ec51c276069c29f23406164803587bd06 (diff)
downloadgcc-646204de717040064c18c189e29a32d0d33fd08b.zip
gcc-646204de717040064c18c189e29a32d0d33fd08b.tar.gz
gcc-646204de717040064c18c189e29a32d0d33fd08b.tar.bz2
[Ada] CCG: regressions on ACATS c460007, c46013a, cd1009d
2020-06-02 Javier Miranda <miranda@adacore.com> gcc/ada/ * exp_ch4.adb (Generate_Temporary): New subprogram of Discrete_Range_Check that generates a temporary to facilitate the C backend the code generation of the unchecked conversion since the size of the source type may differ from the size of the target type.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_ch4.adb52
1 files changed, 52 insertions, 0 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 0a9ecb8..2d63f7e 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -11144,6 +11144,51 @@ package body Exp_Ch4 is
Expr : Node_Id;
Ityp : Entity_Id;
+ procedure Generate_Temporary;
+ -- Generate a temporary to facilitate in the C backend the code
+ -- generation of the unchecked conversion since the size of the
+ -- source type may differ from the size of the target type.
+
+ ------------------------
+ -- Generate_Temporary --
+ ------------------------
+
+ procedure Generate_Temporary is
+ begin
+ if Esize (Etype (Expr)) < Esize (Etype (Ityp)) then
+ declare
+ Exp_Type : constant Entity_Id := Ityp;
+ Def_Id : constant Entity_Id :=
+ Make_Temporary (Loc, 'R', Expr);
+ E : Node_Id;
+ Res : Node_Id;
+
+ begin
+ Set_Is_Internal (Def_Id);
+ Set_Etype (Def_Id, Exp_Type);
+ Res := New_Occurrence_Of (Def_Id, Loc);
+
+ E :=
+ Make_Object_Declaration (Loc,
+ Defining_Identifier => Def_Id,
+ Object_Definition => New_Occurrence_Of
+ (Exp_Type, Loc),
+ Constant_Present => True,
+ Expression => Relocate_Node (Expr));
+
+ Set_Assignment_OK (E);
+ Insert_Action (Expr, E);
+
+ Set_Assignment_OK (Res, Assignment_OK (Expr));
+
+ Rewrite (Expr, Res);
+ Analyze_And_Resolve (Expr, Exp_Type);
+ end;
+ end if;
+ end Generate_Temporary;
+
+ -- Start of processing for Discrete_Range_Check
+
begin
-- Nothing to do if conversion was rewritten
@@ -11180,6 +11225,13 @@ package body Exp_Ch4 is
Ityp := Standard_Integer;
end if;
+ -- Generate a temporary with the large type to facilitate in the C
+ -- backend the code generation for the unchecked conversion.
+
+ if Modify_Tree_For_C then
+ Generate_Temporary;
+ end if;
+
Set_Do_Range_Check (Expr, False);
Rewrite (Expr, Unchecked_Convert_To (Ityp, Expr));
end if;