diff options
author | Javier Miranda <miranda@adacore.com> | 2019-12-13 09:04:43 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-12-13 09:04:43 +0000 |
commit | 02458cc74236718edd74f3d4bd6cc259ebbba5ca (patch) | |
tree | 8407065f5c9f7ae391b739c0c18e6785562f0478 /gcc/ada | |
parent | cfedf3e51bbcfc13e014a5b1d98418fe4f50d907 (diff) | |
download | gcc-02458cc74236718edd74f3d4bd6cc259ebbba5ca.zip gcc-02458cc74236718edd74f3d4bd6cc259ebbba5ca.tar.gz gcc-02458cc74236718edd74f3d4bd6cc259ebbba5ca.tar.bz2 |
[Ada] Adding support for unsupported type conversion in CCG
2019-12-13 Javier Miranda <miranda@adacore.com>
gcc/ada/
* exp_ch4.adb (Expand_N_Unchecked_Type_Conversion): Generate an
extra temporary for cases unsupported by the C backend.
From-SVN: r279356
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/exp_ch4.adb | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 69176db..dde5372 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-12-13 Javier Miranda <miranda@adacore.com> + + * exp_ch4.adb (Expand_N_Unchecked_Type_Conversion): Generate an + extra temporary for cases unsupported by the C backend. + 2019-12-13 Steve Baird <baird@adacore.com> * einfo.ads: Correct comment for Derived_Type_Link to reflect diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 1955823..28d48ab 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -12471,6 +12471,27 @@ package body Exp_Ch4 is end; end if; + -- Generate an extra temporary for cases unsupported by the C backend + + if Modify_Tree_For_C then + declare + Source : constant Node_Id := Unqual_Conv (Expression (N)); + Source_Typ : Entity_Id := Get_Full_View (Etype (Source)); + + begin + if Is_Packed_Array (Source_Typ) then + Source_Typ := Packed_Array_Impl_Type (Source_Typ); + end if; + + if Nkind (Source) = N_Function_Call + and then (Is_Composite_Type (Etype (Source)) + or else Is_Composite_Type (Target_Type)) + then + Force_Evaluation (Source); + end if; + end; + end if; + -- Nothing to do if conversion is safe if Safe_Unchecked_Type_Conversion (N) then |