diff options
author | Hristian Kirtchev <kirtchev@adacore.com> | 2019-07-10 09:01:38 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-10 09:01:38 +0000 |
commit | 5b4ce2a0360a79751107c245c2e44c0932835164 (patch) | |
tree | a336c598eb7e8be8d55e2478f01b8aeea26a05f4 /gcc/ada | |
parent | 7f8c1cd3675b0e30817d98e52740b918b4e970b0 (diff) | |
download | gcc-5b4ce2a0360a79751107c245c2e44c0932835164.zip gcc-5b4ce2a0360a79751107c245c2e44c0932835164.tar.gz gcc-5b4ce2a0360a79751107c245c2e44c0932835164.tar.bz2 |
[Ada] Spurious error on case expression with limited result
This patch modifies the expansion of case expressions to prevent a
spurious error caused by the use of assignment statements to capture the
result of the case expression when the associated type is limited.
2019-07-10 Hristian Kirtchev <kirtchev@adacore.com>
gcc/ada/
* exp_ch4.adb (Expand_N_Case_Expression): Mark the generated
assignments to the temporary result as being OK because the
expansion of case expressions is correct by construction.
(Is_Copy_Type): Update the predicate to match the comment
within.
gcc/testsuite/
* gnat.dg/limited2.adb, gnat.dg/limited2_pack_1.adb,
gnat.dg/limited2_pack_1.ads, gnat.dg/limited2_pack_2.adb,
gnat.dg/limited2_pack_2.ads: New testcase.
From-SVN: r273336
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/exp_ch4.adb | 9 |
2 files changed, 14 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f3f7217..adcb6a9 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,13 @@ 2019-07-10 Hristian Kirtchev <kirtchev@adacore.com> + * exp_ch4.adb (Expand_N_Case_Expression): Mark the generated + assignments to the temporary result as being OK because the + expansion of case expressions is correct by construction. + (Is_Copy_Type): Update the predicate to match the comment + within. + +2019-07-10 Hristian Kirtchev <kirtchev@adacore.com> + * bindo-graphs.adb, bindo.adb, debug.adb, exp_ch6.adb, sem_ch10.adb, sem_ch13.adb, sem_ch3.adb, sem_ch4.adb, sem_ch6.adb, sem_ch7.adb, sem_res.adb, sem_spark.adb, diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index b4159a7..f18632a 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -5087,7 +5087,6 @@ package body Exp_Ch4 is ------------------------------ procedure Expand_N_Case_Expression (N : Node_Id) is - function Is_Copy_Type (Typ : Entity_Id) return Boolean; -- Return True if we can copy objects of this type when expanding a case -- expression. @@ -5106,7 +5105,7 @@ package body Exp_Ch4 is or else (Minimize_Expression_With_Actions and then Is_Constrained (Underlying_Type (Typ)) - and then not Is_Limited_View (Underlying_Type (Typ))); + and then not Is_Limited_Type (Underlying_Type (Typ))); end Is_Copy_Type; -- Local variables @@ -5283,6 +5282,7 @@ package body Exp_Ch4 is declare Alt_Expr : Node_Id := Expression (Alt); Alt_Loc : constant Source_Ptr := Sloc (Alt_Expr); + LHS : Node_Id; Stmts : List_Id; begin @@ -5312,9 +5312,12 @@ package body Exp_Ch4 is -- Target := AX['Unrestricted_Access]; else + LHS := New_Occurrence_Of (Target, Loc); + Set_Assignment_OK (LHS); + Stmts := New_List ( Make_Assignment_Statement (Alt_Loc, - Name => New_Occurrence_Of (Target, Loc), + Name => LHS, Expression => Alt_Expr)); end if; |