* sem_ch5.adb (Analyze_Iterator_Specification): Set kind of
loop variable after pre-analysis of iterator name, to prevent
premature usage of loop variable.
2012-05-15 Ed Schonberg <schonberg@adacore.com>
* sem_util.adb (Is_Variable): In Ada 2012, an explicit
dereference that is a rewriting of an expression whose type has
a declared Implicit_Derenference aspect is a variable.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187531
138bc75d-0d04-0410-961f-
82ee72b054a4
+2012-05-15 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch5.adb (Analyze_Iterator_Specification): Set kind of
+ loop variable after pre-analysis of iterator name, to prevent
+ premature usage of loop variable.
+
+2012-05-15 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_util.adb (Is_Variable): In Ada 2012, an explicit
+ dereference that is a rewriting of an expression whose type has
+ a declared Implicit_Derenference aspect is a variable.
+
2012-05-15 Hristian Kirtchev <kirtchev@adacore.com>
* exp_ch4.adb (Insert_Dereference_Action): Reimplemented. The
begin
Enter_Name (Def_Id);
- Set_Ekind (Def_Id, E_Variable);
if Present (Subt) then
Analyze (Subt);
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
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,
or else
Is_Variable_Prefix (Original_Node (Prefix (N)));
- -- A function call is never a variable
+ -- in Ada 2012, the dereference may have been added for a type with
+ -- a declared implicit dereference aspect.
+
+ elsif Nkind (N) = N_Explicit_Dereference
+ and then Present (Etype (Orig_Node))
+ and then Ada_Version >= Ada_2012
+ and then Has_Implicit_Dereference (Etype (Orig_Node))
+ then
+ return True;
+
+ -- A function call is never a variable.
elsif Nkind (N) = N_Function_Call then
return False;