===================================================================
@@ -18656,11 +18656,14 @@
is
begin
-- An object of a limited interface type can be initialized with any
- -- expression of a nonlimited descendant type.
+ -- expression of a nonlimited descendant type. However this does not
+ -- apply if this is a view conversion of some other expression. This
+ -- is checked below.
if Is_Class_Wide_Type (Typ)
and then Is_Limited_Interface (Typ)
and then not Is_Limited_Type (Etype (Exp))
+ and then Nkind (Exp) /= N_Type_Conversion
then
return True;
end if;
===================================================================
@@ -4767,13 +4767,21 @@
and then not In_Instance_Body
then
if not OK_For_Limited_Init (Etype (E), Expression (E)) then
- Error_Msg_N ("initialization not allowed for limited types", N);
+ if Nkind (Parent (N)) = N_Assignment_Statement then
+ Error_Msg_N
+ ("illegal expression for initialized allocator of a "
+ & "limited type (RM 7.5 (2.7/2))", N);
+ else
+ Error_Msg_N
+ ("initialization not allowed for limited types", N);
+ end if;
+
Explain_Limited_Type (Etype (E), N);
end if;
end if;
- -- A qualified expression requires an exact match of the type.
- -- Class-wide matching is not allowed.
+ -- A qualified expression requires an exact match of the type. Class-
+ -- wide matching is not allowed.
if (Is_Class_Wide_Type (Etype (Expression (E)))
or else Is_Class_Wide_Type (Etype (E)))