diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2018-10-09 15:06:35 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-10-09 15:06:35 +0000 |
commit | e693ddbec3e38aeff2e229785b9037ba0caa17c8 (patch) | |
tree | c2982d7ce8279b96ff13045aa674032b22d111e4 /gcc/ada | |
parent | 38c2f655ffa5cf2f335c2772ec484702d891a7c3 (diff) | |
download | gcc-e693ddbec3e38aeff2e229785b9037ba0caa17c8.zip gcc-e693ddbec3e38aeff2e229785b9037ba0caa17c8.tar.gz gcc-e693ddbec3e38aeff2e229785b9037ba0caa17c8.tar.bz2 |
[Ada] Fix spurious error on derived record passed as Out parameter
This fixlet gets rid of a spurious error issued in the specific case of
a call to a subprogram taking an Out parameter of a discriminated record
type without default discriminants, if the actual parameter is the
result of the conversion to the record type of a variable whose type is
derived from the record and has a representation clause.
The compiler was failing to initialize the temporary made around the
call because of the representation clause, but this is required for a
type with discriminants because discriminants may be read by the called
subprogram.
2018-10-09 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* exp_ch6.adb (Add_Call_By_Copy_Code): Initialize the temporary
made for an Out parameter if the formal type has discriminants.
gcc/testsuite/
* gnat.dg/derived_type5.adb, gnat.dg/derived_type5_pkg.ads: New
testcase.
From-SVN: r264980
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/exp_ch6.adb | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index fada99d..854cadd 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-10-09 Eric Botcazou <ebotcazou@adacore.com> + + * exp_ch6.adb (Add_Call_By_Copy_Code): Initialize the temporary + made for an Out parameter if the formal type has discriminants. + 2018-10-09 Maroua Maalej <maalej@adacore.com> * sem_spark.adb (Check_Declaration): fix bug related to non diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 2988f77..076e0c2 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -1321,8 +1321,14 @@ package body Exp_Ch6 is -- bounds of the actual and build an uninitialized temporary of the -- right size. + -- If the formal is an out parameter with discriminants, the + -- discriminants must be captured even if the rest of the object + -- is in principle uninitialized, because the discriminants may + -- be read by the called subprogram. + if Ekind (Formal) = E_In_Out_Parameter or else (Is_Array_Type (F_Typ) and then not Is_Constrained (F_Typ)) + or else Has_Discriminants (F_Typ) then if Nkind (Actual) = N_Type_Conversion then if Conversion_OK (Actual) then |