summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch5.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/sem_ch5.adb')
-rw-r--r--gcc/ada/sem_ch5.adb13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index ba94d77f1c4..749393b5d78 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -1650,7 +1650,6 @@ package body Sem_Ch5 is
begin
Enter_Name (Def_Id);
- Set_Ekind (Def_Id, E_Variable);
if Present (Subt) then
Analyze (Subt);
@@ -1658,6 +1657,11 @@ package body Sem_Ch5 is
Preanalyze_Range (Iter_Name);
+ -- Set the kind of the loop variable, which is not visible within
+ -- the iterator name.
+
+ Set_Ekind (Def_Id, E_Variable);
+
-- If the domain of iteration is an expression, create a declaration for
-- it, so that finalization actions are introduced outside of the loop.
-- The declaration must be a renaming because the body of the loop may
@@ -1679,6 +1683,13 @@ package body Sem_Ch5 is
begin
Typ := Etype (Iter_Name);
+ -- Protect against malformed iterator
+
+ if Typ = Any_Type then
+ Error_Msg_N ("invalid expression in loop iterator", Iter_Name);
+ return;
+ end if;
+
-- The name in the renaming declaration may be a function call.
-- Indicate that it does not come from source, to suppress
-- spurious warnings on renamings of parameterless functions,