+2015-05-21 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch13.adb (Check_Iterator_Functions): Emit error on Iterator
+ aspect as well when indexing function is illegal.
+ (Valid_Default_Iterator): Handle properly somme illegal cases
+ to prevent compilation abandoned messages.
+ (Check_Primitive_Function): Verify that type and indexing function
+ are in the same scope.
+ * freeze.adb (Freeze_Record): Extend patch on the presence of
+ indexing aspects to aspect Default_Iterator.
+
2015-05-19 David Malcolm <dmalcolm@redhat.com>
* gcc-interface/trans.c (Sloc_to_locus1): Strenghthen local "map"
Set_Etype (Formal, F_Type);
end if;
- Freeze_And_Append (F_Type, N, Result);
+ if not From_Limited_With (F_Type) then
+ Freeze_And_Append (F_Type, N, Result);
+ end if;
if Is_Private_Type (F_Type)
and then Is_Private_Type (Base_Type (F_Type))
end if;
end if;
- -- Make sure that if we have aspect Iterator_Element, then we have
+ -- Make sure that if we have terator aspect, then we have
-- either Constant_Indexing or Variable_Indexing.
- if Has_Aspect (Rec, Aspect_Iterator_Element) then
- if Has_Aspect (Rec, Aspect_Constant_Indexing)
+ declare
+ Iterator_Aspect : Node_Id;
+
+ begin
+ Iterator_Aspect := Find_Aspect (Rec, Aspect_Iterator_Element);
+
+ if No (Iterator_Aspect) then
+ Iterator_Aspect := Find_Aspect (Rec, Aspect_Default_Iterator);
+ end if;
+
+ if Present (Iterator_Aspect) 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));
+ Has_Aspect (Rec, Aspect_Variable_Indexing)
+ then
+ null;
+ else
+ Error_Msg_N
+ ("Iterator_Element requires indexing aspect",
+ Iterator_Aspect);
+ end if;
end if;
- end if;
+ end;
-- All done if not a full record definition
Entity (Expr), Ent);
end if;
+ -- Flag the default_iterator as well as the denoted function.
+
if not Valid_Default_Iterator (Entity (Expr)) then
- Error_Msg_N ("improper function for default iterator", Expr);
+ Error_Msg_N ("improper function for default iterator!", Expr);
end if;
else
Ctrl := Etype (First_Formal (Subp));
end if;
+ -- To be a primitive operation subprogram has to be in same scope.
+
+ if Scope (Ctrl) /= Scope (Subp) then
+ return False;
+ end if;
+
-- Type of formal may be the class-wide type, an access to such,
-- or an incomplete view.
Typ : Entity_Id;
begin
+ -- If target type is untagged, further checks are irrelevant
+
if not Is_Tagged_Type (U_Ent) then
Error_Msg_N
- ("aspect Default_Iterator applies to tagged type", Nam);
+ ("aspect Default_Iterator applies to tagged type", Nam);
+ return;
end if;
Check_Iterator_Functions;
or else Ekind (Entity (Expr)) /= E_Function
then
Error_Msg_N ("aspect Iterator must be a function", Expr);
+ return;
else
Func := Entity (Expr);
end if;
-- The type of the first parameter must be T, T'class, or a
- -- corresponding access type (5.5.1 (8/3)
+ -- corresponding access type (5.5.1 (8/3). If function is
+ -- parameterless label type accordingly.
if No (First_Formal (Func)) then
- Typ := Empty;
+ Typ := Any_Type;
else
Typ := Etype (First_Formal (Func));
end if;