[multiple changes]
2015-05-12 Ed Schonberg <schonberg@adacore.com> * sem_ch5.adb (Analyze_Iterator_Specifications): Additional legality checks for array and container iterators: a) The domain of iteration cannot be a component that depends on discriminants of a mutable object. The check was recently added for element iterators. b) The cursor type cannot be a limited type at the point of the iteration, because the cursor will be assigned to in the body of the loop. 2015-05-12 Robert Dewar <dewar@adacore.com> * freeze.adb (Freeze_Record_Type): Make sure that if we have aspect Iterator_Element, then we have either Constant_Indexing or Variable_Indexing. From-SVN: r223077
This commit is contained in:
parent
4b17187f23
commit
7166d53559
|
@ -1,3 +1,20 @@
|
|||
2015-05-12 Ed Schonberg <schonberg@adacore.com>
|
||||
|
||||
* sem_ch5.adb (Analyze_Iterator_Specifications): Additional
|
||||
legality checks for array and container iterators:
|
||||
a) The domain of iteration cannot be a component that depends
|
||||
on discriminants of a mutable object. The check was recently
|
||||
added for element iterators.
|
||||
b) The cursor type cannot be a limited type at the point of the
|
||||
iteration, because the cursor will be assigned to in the body
|
||||
of the loop.
|
||||
|
||||
2015-05-12 Robert Dewar <dewar@adacore.com>
|
||||
|
||||
* freeze.adb (Freeze_Record_Type): Make sure that if we have
|
||||
aspect Iterator_Element, then we have either Constant_Indexing
|
||||
or Variable_Indexing.
|
||||
|
||||
2015-05-12 Ed Schonberg <schonberg@adacore.com>
|
||||
|
||||
* a-coormu.ads, a-coormu.adb: Add Indexing aspect, Reference_Type,
|
||||
|
|
|
@ -4288,6 +4288,22 @@ package body Freeze is
|
|||
end if;
|
||||
end if;
|
||||
|
||||
-- Make sure that if we have aspect Iterator_Element, then we have
|
||||
-- either Constant_Indexing or Variable_Indexing.
|
||||
|
||||
if Has_Aspect (Rec, Aspect_Iterator_Element) then
|
||||
if Has_Aspect (Rec, Aspect_Constant_Indexing)
|
||||
or else
|
||||
Has_Aspect (Rec, Aspect_Variable_Indexing)
|
||||
then
|
||||
null;
|
||||
else
|
||||
Error_Msg_N
|
||||
("Iterator_Element requires indexing aspect",
|
||||
Find_Aspect (Rec, Aspect_Iterator_Element));
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- All done if not a full record definition
|
||||
|
||||
if Ekind (Rec) /= E_Record_Type then
|
||||
|
|
|
@ -2088,7 +2088,7 @@ package body Sem_Ch5 is
|
|||
end;
|
||||
end if;
|
||||
|
||||
-- OF not present
|
||||
-- IN iterator, domain is a range, or a call to Iterate function
|
||||
|
||||
else
|
||||
-- For an iteration of the form IN, the name must denote an
|
||||
|
@ -2125,6 +2125,35 @@ package body Sem_Ch5 is
|
|||
end if;
|
||||
end if;
|
||||
|
||||
-- If the name is a call (typically prefixed) to some Iterate
|
||||
-- function, it has been rewritten as an object declaration.
|
||||
-- If that object is a selected component, verify that it is not
|
||||
-- a component of an unconstrained mutable object.
|
||||
|
||||
if Nkind (Iter_Name) = N_Identifier then
|
||||
declare
|
||||
Iter_Kind : constant Node_Kind :=
|
||||
Nkind (Original_Node (Iter_Name));
|
||||
Obj : Node_Id;
|
||||
|
||||
begin
|
||||
if Iter_Kind = N_Selected_Component then
|
||||
Obj := Prefix (Original_Node (Iter_Name));
|
||||
|
||||
elsif Iter_Kind = N_Function_Call then
|
||||
Obj := First_Actual (Original_Node (Iter_Name));
|
||||
end if;
|
||||
|
||||
if Nkind (Obj) = N_Selected_Component
|
||||
and then Is_Dependent_Component_Of_Mutable_Object (Obj)
|
||||
then
|
||||
Error_Msg_N
|
||||
("container cannot be a discriminant-dependent " &
|
||||
"component of a mutable object", N);
|
||||
end if;
|
||||
end;
|
||||
end if;
|
||||
|
||||
-- The result type of Iterate function is the classwide type of
|
||||
-- the interface parent. We need the specific Cursor type defined
|
||||
-- in the container package. We obtain it by name for a predefined
|
||||
|
@ -2148,6 +2177,13 @@ package body Sem_Ch5 is
|
|||
Next_Entity (Ent);
|
||||
end loop;
|
||||
end if;
|
||||
|
||||
-- The cursor is the target of generated assignments in the
|
||||
-- loop, and cannot have a limited type.
|
||||
|
||||
if Is_Limited_Type (Etype (Def_Id)) then
|
||||
Error_Msg_N ("cursor type cannot be limited", N);
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
|
|
Loading…
Reference in New Issue