===================================================================
@@ -506,6 +506,15 @@
Ghost_Mode := Save_Ghost_Mode;
return;
+ -- A class-wide type may be a limited view. This illegal case is not
+ -- caught by previous checks.
+
+ elsif Ekind (T1) = E_Class_Wide_Type
+ and then From_Limited_With (T1)
+ then
+ Error_Msg_NE ("invalid use of limited view of&", Lhs, T1);
+ return;
+
-- Enforce RM 3.9.3 (8): the target of an assignment operation cannot be
-- abstract. This is only checked when the assignment Comes_From_Source,
-- because in some cases the expander generates such assignments (such
===================================================================
@@ -2786,7 +2786,10 @@
procedure Detect_And_Exchange (Id : Entity_Id);
-- Determine whether Id's type denotes an incomplete type associated
-- with a limited with clause and exchange the limited view with the
- -- non-limited one when available.
+ -- non-limited one when available. Note that the non-limited view
+ -- may exist because of a with_clause in another unit in the context,
+ -- but cannot be used because the current view of the enclosing unit
+ -- is still a limited view.
-------------------------
-- Detect_And_Exchange --
@@ -2795,7 +2798,10 @@
procedure Detect_And_Exchange (Id : Entity_Id) is
Typ : constant Entity_Id := Etype (Id);
begin
- if From_Limited_With (Typ) and then Has_Non_Limited_View (Typ) then
+ if From_Limited_With (Typ)
+ and then Has_Non_Limited_View (Typ)
+ and then not From_Limited_With (Scope (Typ))
+ then
Set_Etype (Id, Non_Limited_View (Typ));
end if;
end Detect_And_Exchange;