diff options
author | Ronan Desplanques <desplanques@adacore.com> | 2024-07-04 15:43:04 +0200 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-08-02 09:08:03 +0200 |
commit | 99337cb2385c38182e48a491442da449c028f51c (patch) | |
tree | a10660bebc38da6e5d1b8bd9ac42d4a3c7cb3aad | |
parent | d80dcff99f3ca8721eecd82097281095a3122079 (diff) | |
download | gcc-99337cb2385c38182e48a491442da449c028f51c.zip gcc-99337cb2385c38182e48a491442da449c028f51c.tar.gz gcc-99337cb2385c38182e48a491442da449c028f51c.tar.bz2 |
ada: Fix detection of suspicious loop patterns
This patch fixes an assertion failure in some cases in the code to
warn about possible misuse of range attributes in loop. The root of
the problem is that this code failed to consider the case where the
outer loop is a while loop.
Also fix a typo in a nearby comment.
gcc/ada/
* sem_ch5.adb (Analyze_Loop_Statement): Fix loop pattern detection
code. Fix typo.
-rw-r--r-- | gcc/ada/sem_ch5.adb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index e450603..4db3a1a 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -3967,7 +3967,7 @@ package body Sem_Ch5 is Push_Scope (Ent); Analyze_Iteration_Scheme (Iter); - -- Check for following case which merits a warning if the type E of is + -- Check for following case which merits a warning if the type of E is -- a multi-dimensional array (and no explicit subscript ranges present). -- for J in E'Range @@ -3992,6 +3992,10 @@ package body Sem_Ch5 is and then Number_Dimensions (Typ) > 1 and then Nkind (Parent (N)) = N_Loop_Statement and then Present (Iteration_Scheme (Parent (N))) + -- The next conjunct tests that the enclosing loop is + -- a for loop and not a while loop. + and then Present (Loop_Parameter_Specification + (Iteration_Scheme (Parent (N)))) then declare OIter : constant Node_Id := |