diff options
author | Justin Squirek <squirek@adacore.com> | 2020-02-28 10:21:38 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-09 04:09:02 -0400 |
commit | bf2480e2fbf29772f8acca9d184f18dbfb6d00bc (patch) | |
tree | c96da3a4c0db4d0ce52b9a47fe4a43944dd01d86 /gcc | |
parent | 059a704a4195f49c299ab0e92f772df39a27971a (diff) | |
download | gcc-bf2480e2fbf29772f8acca9d184f18dbfb6d00bc.zip gcc-bf2480e2fbf29772f8acca9d184f18dbfb6d00bc.tar.gz gcc-bf2480e2fbf29772f8acca9d184f18dbfb6d00bc.tar.bz2 |
[Ada] Crash on exit statement within predicated loop
2020-06-09 Justin Squirek <squirek@adacore.com>
gcc/ada/
* exp_ch5.adb (Expand_Predicated_Loop): Perserve the original
loop identifier within the expansion.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/exp_ch5.adb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index d69e147..02e9f46 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -4920,13 +4920,14 @@ package body Exp_Ch5 is -- mode, the semantic analyzer may disallow one or both forms. procedure Expand_Predicated_Loop (N : Node_Id) is - Loc : constant Source_Ptr := Sloc (N); - Isc : constant Node_Id := Iteration_Scheme (N); - LPS : constant Node_Id := Loop_Parameter_Specification (Isc); - Loop_Id : constant Entity_Id := Defining_Identifier (LPS); - Ltype : constant Entity_Id := Etype (Loop_Id); - Stat : constant List_Id := Static_Discrete_Predicate (Ltype); - Stmts : constant List_Id := Statements (N); + Orig_Loop_Id : Node_Id := Empty; + Loc : constant Source_Ptr := Sloc (N); + Isc : constant Node_Id := Iteration_Scheme (N); + LPS : constant Node_Id := Loop_Parameter_Specification (Isc); + Loop_Id : constant Entity_Id := Defining_Identifier (LPS); + Ltype : constant Entity_Id := Etype (Loop_Id); + Stat : constant List_Id := Static_Discrete_Predicate (Ltype); + Stmts : constant List_Id := Statements (N); begin -- Case of iteration over non-static predicate, should not be possible @@ -5205,7 +5206,13 @@ package body Exp_Ch5 is Alternatives => Alts); Append_To (Stmts, Cstm); - -- Rewrite the loop + -- Rewrite the loop preserving the loop identifier in case there + -- are exit statements referencing it. + + if Present (Identifier (N)) then + Orig_Loop_Id := New_Occurrence_Of + (Entity (Identifier (N)), Loc); + end if; Set_Suppress_Assignment_Checks (D); @@ -5217,6 +5224,7 @@ package body Exp_Ch5 is Statements => New_List ( Make_Loop_Statement (Loc, Statements => Stmts, + Identifier => Orig_Loop_Id, End_Label => Empty))))); Analyze (N); |