aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-05-17 17:05:14 +0200
committerEric Botcazou <ebotcazou@adacore.com>2023-06-15 16:46:50 +0200
commit3b66becf77e7ae6a36a2e97ec386ff21c9f2b5ff (patch)
tree72de2279acb1d968bdb64a8fb9a3607f16746f1c /gcc
parentf829733b5c92877247727347246d9f927372f0c1 (diff)
downloadgcc-3b66becf77e7ae6a36a2e97ec386ff21c9f2b5ff.zip
gcc-3b66becf77e7ae6a36a2e97ec386ff21c9f2b5ff.tar.gz
gcc-3b66becf77e7ae6a36a2e97ec386ff21c9f2b5ff.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_ch5.adb1
-rw-r--r--gcc/ada/sem_ch5.adb11
-rw-r--r--gcc/ada/sinfo.ads5
3 files changed, 13 insertions, 4 deletions
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index 265e1a7..d605f75 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -5610,6 +5610,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 ab5a208..6b8f9e4 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -2853,10 +2853,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;
@@ -3570,8 +3570,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 c25db08..79fef3e 100644
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -1899,6 +1899,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