Commit de5cd98e by Thomas Quinot Committed by Arnaud Charlet

2008-05-20 Thomas Quinot <quinot@adacore.com>

	* sem_cat.adb
	(Set_Categorization_From_Scope): Do not set In_Remote_Types unless in
	the visible part of the spec of a remote types unit.
	(Validate_Remote_Access_Object_Type_Declaration):
	New local subprogram Is_Valid_Remote_Object_Type, replaces
	Is_Recursively_Limited_Private.
	(Validate_RACW_Primitives): Enforce E.2.2(14) rules: the types of all
	non-controlling formals (and the return type, even though this is not
	explicit in the standard) must support external streaming.
	(Validate_RCI_Subprogram_Declaration): Enforce E.2.3(14) rules: same
	as above for of RAS types and RCI subprograms. (The return type is not
	checked yet).
	Update comments related to RACWs designating limited interfaces per
	ARG ruling on AI05-060.

	* sem_util.ads, sem_util.adb
	(Is_Remote_Access_To_Class_Wide_Type): Only rely on Is_Remote_Types and
	Is_Remote_Call_Interface to identify RACW types in a stable and
	consistent way. We used to rely in this predicate on the privateness of
	the designated type and its ancestors, but depending on the currently
	visible private parts, this caused false negatives. We now uniformly
	rely on checks made at the point where the RACW type is declared.
	(Inspect_Deferred_Constant_Completion): Moved from Sem_Ch7.

From-SVN: r135637
parent 1543e3ab
...@@ -1992,7 +1992,6 @@ package body Sem_Util is ...@@ -1992,7 +1992,6 @@ package body Sem_Util is
function Current_Subprogram return Entity_Id is function Current_Subprogram return Entity_Id is
Scop : constant Entity_Id := Current_Scope; Scop : constant Entity_Id := Current_Scope;
begin begin
if Is_Subprogram (Scop) or else Is_Generic_Subprogram (Scop) then if Is_Subprogram (Scop) or else Is_Generic_Subprogram (Scop) then
return Scop; return Scop;
...@@ -5510,6 +5509,41 @@ package body Sem_Util is ...@@ -5510,6 +5509,41 @@ package body Sem_Util is
end if; end if;
end Insert_Explicit_Dereference; end Insert_Explicit_Dereference;
------------------------------------------
-- Inspect_Deferred_Constant_Completion --
------------------------------------------
procedure Inspect_Deferred_Constant_Completion (Decls : List_Id) is
Decl : Node_Id;
begin
Decl := First (Decls);
while Present (Decl) loop
-- Deferred constant signature
if Nkind (Decl) = N_Object_Declaration
and then Constant_Present (Decl)
and then No (Expression (Decl))
-- No need to check internally generated constants
and then Comes_From_Source (Decl)
-- The constant is not completed. A full object declaration
-- or a pragma Import complete a deferred constant.
and then not Has_Completion (Defining_Identifier (Decl))
then
Error_Msg_N
("constant declaration requires initialization expression",
Defining_Identifier (Decl));
end if;
Decl := Next (Decl);
end loop;
end Inspect_Deferred_Constant_Completion;
------------------- -------------------
-- Is_AAMP_Float -- -- Is_AAMP_Float --
------------------- -------------------
...@@ -6740,60 +6774,13 @@ package body Sem_Util is ...@@ -6740,60 +6774,13 @@ package body Sem_Util is
function Is_Remote_Access_To_Class_Wide_Type function Is_Remote_Access_To_Class_Wide_Type
(E : Entity_Id) return Boolean (E : Entity_Id) return Boolean
is is
D : Entity_Id;
function Comes_From_Limited_Private_Type_Declaration
(E : Entity_Id) return Boolean;
-- Check that the type is declared by a limited type declaration,
-- or else is derived from a Remote_Type ancestor through private
-- extensions.
-------------------------------------------------
-- Comes_From_Limited_Private_Type_Declaration --
-------------------------------------------------
function Comes_From_Limited_Private_Type_Declaration
(E : Entity_Id) return Boolean
is
N : constant Node_Id := Declaration_Node (E);
begin
if Nkind (N) = N_Private_Type_Declaration
and then Limited_Present (N)
then
return True;
end if;
if Nkind (N) = N_Private_Extension_Declaration then
return
Comes_From_Limited_Private_Type_Declaration (Etype (E))
or else
(Is_Remote_Types (Etype (E))
and then Is_Limited_Record (Etype (E))
and then Has_Private_Declaration (Etype (E)));
end if;
return False;
end Comes_From_Limited_Private_Type_Declaration;
-- Start of processing for Is_Remote_Access_To_Class_Wide_Type
begin begin
if not (Is_Remote_Call_Interface (E) -- A remote access to class-wide type is a general access to object type
or else Is_Remote_Types (E)) -- declared in the visible part of a Remote_Types or Remote_Call_
or else Ekind (E) /= E_General_Access_Type -- Interface unit.
then
return False;
end if;
D := Designated_Type (E);
if Ekind (D) /= E_Class_Wide_Type then
return False;
end if;
return Comes_From_Limited_Private_Type_Declaration return Ekind (E) = E_General_Access_Type
(Defining_Identifier (Parent (D))); and then (Is_Remote_Call_Interface (E) or else Is_Remote_Types (E));
end Is_Remote_Access_To_Class_Wide_Type; end Is_Remote_Access_To_Class_Wide_Type;
----------------------------------------- -----------------------------------------
...@@ -6807,8 +6794,7 @@ package body Sem_Util is ...@@ -6807,8 +6794,7 @@ package body Sem_Util is
return (Ekind (E) = E_Access_Subprogram_Type return (Ekind (E) = E_Access_Subprogram_Type
or else (Ekind (E) = E_Record_Type or else (Ekind (E) = E_Record_Type
and then Present (Corresponding_Remote_Type (E)))) and then Present (Corresponding_Remote_Type (E))))
and then (Is_Remote_Call_Interface (E) and then (Is_Remote_Call_Interface (E) or else Is_Remote_Types (E));
or else Is_Remote_Types (E));
end Is_Remote_Access_To_Subprogram_Type; end Is_Remote_Access_To_Subprogram_Type;
-------------------- --------------------
...@@ -6863,8 +6849,8 @@ package body Sem_Util is ...@@ -6863,8 +6849,8 @@ package body Sem_Util is
Subp_Decl : Node_Id := Parent (Parent (Proc_Nam)); Subp_Decl : Node_Id := Parent (Parent (Proc_Nam));
function Is_Entry (Nam : Node_Id) return Boolean; function Is_Entry (Nam : Node_Id) return Boolean;
-- Determine whether Nam is an entry. Traverse selectors -- Determine whether Nam is an entry. Traverse selectors if there are
-- if there are nested selected components. -- nested selected components.
-------------- --------------
-- Is_Entry -- -- Is_Entry --
......
...@@ -547,10 +547,10 @@ package Sem_Util is ...@@ -547,10 +547,10 @@ package Sem_Util is
function Has_Overriding_Initialize (T : Entity_Id) return Boolean; function Has_Overriding_Initialize (T : Entity_Id) return Boolean;
-- Predicate to determine whether a controlled type has a user-defined -- Predicate to determine whether a controlled type has a user-defined
-- initialize procedure, which makes the type not preelaborable. -- Initialize primitive, which makes the type not preelaborable.
function Has_Preelaborable_Initialization (E : Entity_Id) return Boolean; function Has_Preelaborable_Initialization (E : Entity_Id) return Boolean;
-- Return True iff type E has preelaborable initialisation as defined in -- Return True iff type E has preelaborable initialization as defined in
-- Ada 2005 (see AI-161 for details of the definition of this attribute). -- Ada 2005 (see AI-161 for details of the definition of this attribute).
function Has_Private_Component (Type_Id : Entity_Id) return Boolean; function Has_Private_Component (Type_Id : Entity_Id) return Boolean;
...@@ -611,6 +611,11 @@ package Sem_Util is ...@@ -611,6 +611,11 @@ package Sem_Util is
-- N (which is the prefix, e.g. of an indexed component) as an -- N (which is the prefix, e.g. of an indexed component) as an
-- explicit dereference. -- explicit dereference.
procedure Inspect_Deferred_Constant_Completion (Decls : List_Id);
-- Examine all deferred constants in the declaration list Decls and check
-- whether they have been completed by a full constant declaration or an
-- Import pragma. Emit the error message if that is not the case.
function Is_AAMP_Float (E : Entity_Id) return Boolean; function Is_AAMP_Float (E : Entity_Id) return Boolean;
-- Defined for all type entities. Returns True only for the base type -- Defined for all type entities. Returns True only for the base type
-- of float types with AAMP format. The particular format is determined -- of float types with AAMP format. The particular format is determined
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment