diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-10-10 14:32:30 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-10-10 14:32:30 +0000 |
commit | a9687a3e9ed9913cefcb6ed8eee0f5239b6c78dc (patch) | |
tree | 61cbeeedcbb69a0c2d6e113c5f6afb4a66672e5c /gcc/ada/sem_ch5.adb | |
parent | 2dd9fd37811882a2c5cdcd0880c20e507256e10f (diff) | |
download | gcc-a9687a3e9ed9913cefcb6ed8eee0f5239b6c78dc.tar.gz |
2014-10-10 Gary Dismukes <dismukes@adacore.com>
* sinfo.ads, gnat_ugn.texi, a-except.adb, a-except-2005.adb,
raise-gcc.c Spelling changes (prolog => prologue, epilog => epilogue).
2014-10-10 Ed Schonberg <schonberg@adacore.com>
* sem_ch5.adb (Is_Wrapped_In_Block): Handle properly blocks that
contain pragmas generated for loop invariants and type predicates.
Clarify use of this subprogram.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216087 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_ch5.adb')
-rw-r--r-- | gcc/ada/sem_ch5.adb | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index b80efcec704..1e731f887a7 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -2855,7 +2855,10 @@ package body Sem_Ch5 is -- container iteration. function Is_Wrapped_In_Block (N : Node_Id) return Boolean; - -- Determine whether node N is the sole statement of a block + -- Determine whether loop statement N has been wrapped in a block to + -- capture finalization actions that may be generated for container + -- iterators. Prevents infinite recursion when block is analyzed. + -- Routine is a noop if loop is single statement within source block. --------------------------- -- Is_Container_Iterator -- @@ -2919,14 +2922,27 @@ package body Sem_Ch5 is ------------------------- function Is_Wrapped_In_Block (N : Node_Id) return Boolean is - HSS : constant Node_Id := Parent (N); + HSS : Node_Id; + Stat : Node_Id; begin - return - Nkind (HSS) = N_Handled_Sequence_Of_Statements - and then Nkind (Parent (HSS)) = N_Block_Statement - and then First (Statements (HSS)) = N - and then No (Next (First (Statements (HSS)))); + if Ekind (Current_Scope) /= E_Block then + return False; + + else + HSS := + Handled_Statement_Sequence (Parent (Block_Node (Current_Scope))); + + -- Skip leading pragmas that may be introduced for invariant and + -- predicate checks. + + Stat := First (Statements (HSS)); + while Present (Stat) and then Nkind (Stat) = N_Pragma loop + Stat := Next (Stat); + end loop; + + return Stat = N and then No (Next (Stat)); + end if; end Is_Wrapped_In_Block; -- Local declarations |