("?foreign convention function& should not " &
"return unconstrained array!", E);
- -- Ada 2005 (AI-326): Check wrong use of tagged
+ -- Ada 2005 (AI-326): Check wrong use of
-- incomplete type
- -- type T is tagged;
+ -- type T; -- tagged or just incomplete.
-- function F (X : Boolean) return T; -- ERROR
-- The type must be declared in the current scope for the
-- when the construct that mentions it is frozen.
elsif Ekind (Etype (E)) = E_Incomplete_Type
- and then Is_Tagged_Type (Etype (E))
and then No (Full_View (Etype (E)))
and then not Is_Value_Type (Etype (E))
then
- Error_Msg_N
- ("(Ada 2005): invalid use of tagged incomplete type",
- E);
+ Error_Msg_NE
+ ("invalid use of incomplete type&", E, Etype (E));
end if;
end if;
end;
-- For access subprogram, freeze types of all formals, the return
-- type was already frozen, since it is the Etype of the function.
+ -- Formal types can be tagged Taft amendment types, but otherwise
+ -- they cannot be incomplete;
elsif Ekind (E) = E_Subprogram_Type then
Formal := First_Formal (E);
+
while Present (Formal) loop
+ if Ekind (Etype (Formal)) = E_Incomplete_Type
+ and then No (Full_View (Etype (Formal)))
+ and then not Is_Value_Type (Etype (Formal))
+ then
+ if Is_Tagged_Type (Etype (Formal)) then
+ null;
+ else
+ Error_Msg_NE
+ ("invalid use of incomplete type&", E, Etype (Formal));
+ end if;
+ end if;
+
Freeze_And_Append (Etype (Formal), Loc, Result);
Next_Formal (Formal);
end loop;
-- Ada 2005 (AI-326): Check wrong use of tag incomplete type
- -- type T is tagged;
+ -- type T; -- tagged or untagged, may be from limited view;
-- type Acc is access function (X : T) return T; -- ERROR
if Ekind (Etype (E)) = E_Incomplete_Type
- and then Is_Tagged_Type (Etype (E))
and then No (Full_View (Etype (E)))
and then not Is_Value_Type (Etype (E))
then
- Error_Msg_N
- ("(Ada 2005): invalid use of tagged incomplete type", E);
+ Error_Msg_NE
+ ("invalid use of incomplete type&", E, Etype (E));
end if;
-- For access to a protected subprogram, freeze the equivalent type
end if;
if Ekind (Etyp) = E_Incomplete_Type
- and then Is_Tagged_Type (Etyp)
and then No (Full_View (Etyp))
and then not Is_Value_Type (Etype (E))
then
- Error_Msg_N
- ("(Ada 2005): invalid use of tagged incomplete type", E);
+ Error_Msg_NE
+ ("invalid use of incomplete type&", E, Etyp);
end if;
end;