* [Ada] Crash on exit statement within predicated loop
@ 2020-06-09 8:10 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-06-09 8:10 UTC (permalink / raw)
To: gcc-patches; +Cc: Justin Squirek
[-- Attachment #1: Type: text/plain, Size: 403 bytes --]
This patch corrects an issue whereby the compiler would crash if it
encountered an exit statement featuring a loop identifier where such
referenced loop iterates through a predicated type.
Tested on x86_64-pc-linux-gnu, committed on trunk
2020-06-09 Justin Squirek <squirek@adacore.com>
gcc/ada/
* exp_ch5.adb (Expand_Predicated_Loop): Perserve the original
loop identifier within the expansion.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2135 bytes --]
--- gcc/ada/exp_ch5.adb
+++ 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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-09 8:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-09 8:10 [Ada] Crash on exit statement within predicated loop Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).