public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1859] ada: Fix internal error on loop iterator filter with -gnatVa
@ 2023-06-15  8:03 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-06-15  8:03 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a8c45d3fba65fa4e83903ffcba678eb497c2b07b

commit r14-1859-ga8c45d3fba65fa4e83903ffcba678eb497c2b07b
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed May 17 17:05:14 2023 +0200

    ada: Fix internal error on loop iterator filter with -gnatVa
    
    The problem is that the condition of the iterator filter is expanded early,
    before it is integrated into an if statement of the loop body, so there is
    no place to attach the actions generated by this expansion.
    
    This happens only for simple loops, i.e. with a parameter specification, so
    the fix uses the same approach for them as for loops based on iterators.
    
    gcc/ada/
    
            * sinfo.ads (Iterator_Filter): Document field.
            * sem_ch5.adb (Analyze_Iterator_Specification): Move comment around.
            (Analyze_Loop_Parameter_Specification): Only preanalyze the iterator
            filter, if any.
            * exp_ch5.adb (Expand_N_Loop_Statement): Analyze the new list built
            when an iterator filter is present.

Diff:
---
 gcc/ada/exp_ch5.adb |  1 +
 gcc/ada/sem_ch5.adb | 11 +++++++----
 gcc/ada/sinfo.ads   |  5 +++++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index a4c7db9f365..258459b393d 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -5678,6 +5678,7 @@ package body Exp_Ch5 is
                   New_List (Make_If_Statement (Loc,
                     Condition => Iterator_Filter (LPS),
                     Then_Statements => Stats)));
+               Analyze_List (Statements (N));
             end if;
 
             --  Deal with loop over predicates
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index f9174869a26..fa36a5a0741 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -2705,10 +2705,10 @@ package body Sem_Ch5 is
          end if;
       end if;
 
-      if Present (Iterator_Filter (N)) then
-         --  Preanalyze the filter. Expansion will take place when enclosing
-         --  loop is expanded.
+      --  Preanalyze the filter. Expansion will take place when enclosing
+      --  loop is expanded.
 
+      if Present (Iterator_Filter (N)) then
          Preanalyze_And_Resolve (Iterator_Filter (N), Standard_Boolean);
       end if;
    end Analyze_Iterator_Specification;
@@ -3424,8 +3424,11 @@ package body Sem_Ch5 is
          end;
       end if;
 
+      --  Preanalyze the filter. Expansion will take place when enclosing
+      --  loop is expanded.
+
       if Present (Iterator_Filter (N)) then
-         Analyze_And_Resolve (Iterator_Filter (N), Standard_Boolean);
+         Preanalyze_And_Resolve (Iterator_Filter (N), Standard_Boolean);
       end if;
 
       --  A loop parameter cannot be effectively volatile (SPARK RM 7.1.3(4)).
diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads
index 0efbd4479e0..8040a59e175 100644
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -1909,6 +1909,11 @@ package Sinfo is
    --    Present in variable reference markers. Set when the original variable
    --    reference constitutes a write of the variable.
 
+   --  Iterator_Filter
+   --    Present in N_Loop_Parameter_Specification and N_Iterator_Specification
+   --    nodes for Ada 2022. It is used to store the condition present in the
+   --    eponymous Ada 2022 construct.
+
    --  Itype
    --    Used in N_Itype_Reference node to reference an itype for which it is
    --    important to ensure that it is defined. See description of this node

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-15  8:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-15  8:03 [gcc r14-1859] ada: Fix internal error on loop iterator filter with -gnatVa Marc Poulhi?s

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).