Commit 2cee58d8 by Eric Botcazou Committed by Pierre-Marie de Rodat

[Ada] Fully propagate representation aspects through renaming

2019-12-16  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* sem_ch8.adb (Analyze_Object_Renaming): Set Atomic, Independent
	and Volatile_Full_Access aspects on the entity of the renaming
	the same way as the Volatile aspect is set.
	* sem_util.ads (Is_Atomic_Object_Entity): Move declaration to...
	(Is_Independent_Object): New function.
	(Is_Volatile_Full_Access_Object): Likewise.
	* sem_util.adb (Is_Atomic_Object_Entity): ...here.
	(Prefix_Has_Atomic_Components): Minor tweak.
	(Is_Atomic_Object): Test Is_Atomic on the Etype uniformly.
	(Is_Atomic_Or_VFA_Object): Call Is_Volatile_Full_Access_Object.
	(Is_Independent_Object): New predicate.
	(Is_Subcomponent_Of_Atomic_Object): Remove redundant test.
	(Is_Volatile_Full_Access_Object): New predicate.
	(Is_Volatile_Prefix): Rename into...
	(Prefix_Has_Volatile_Components): ... and call
	Is_Volatile_Object.
	(Object_Has_Volatile_Components): Delete.
	(Is_Volatile_Object): Simplify.
	* gcc-interface/trans.c (node_is_volatile_full_access): Adjust
	comment.

From-SVN: r279429
parent 0bba838d
2019-12-16 Eric Botcazou <ebotcazou@adacore.com>
* sem_ch8.adb (Analyze_Object_Renaming): Set Atomic, Independent
and Volatile_Full_Access aspects on the entity of the renaming
the same way as the Volatile aspect is set.
* sem_util.ads (Is_Atomic_Object_Entity): Move declaration to...
(Is_Independent_Object): New function.
(Is_Volatile_Full_Access_Object): Likewise.
* sem_util.adb (Is_Atomic_Object_Entity): ...here.
(Prefix_Has_Atomic_Components): Minor tweak.
(Is_Atomic_Object): Test Is_Atomic on the Etype uniformly.
(Is_Atomic_Or_VFA_Object): Call Is_Volatile_Full_Access_Object.
(Is_Independent_Object): New predicate.
(Is_Subcomponent_Of_Atomic_Object): Remove redundant test.
(Is_Volatile_Full_Access_Object): New predicate.
(Is_Volatile_Prefix): Rename into...
(Prefix_Has_Volatile_Components): ... and call
Is_Volatile_Object.
(Object_Has_Volatile_Components): Delete.
(Is_Volatile_Object): Simplify.
* gcc-interface/trans.c (node_is_volatile_full_access): Adjust
comment.
2019-12-16 Bob Duff <duff@adacore.com> 2019-12-16 Bob Duff <duff@adacore.com>
* par.adb: Add Scopes function to do range checking on the scope * par.adb: Add Scopes function to do range checking on the scope
......
...@@ -4835,8 +4835,8 @@ node_is_atomic (Node_Id gnat_node) ...@@ -4835,8 +4835,8 @@ node_is_atomic (Node_Id gnat_node)
} }
/* Return true if GNAT_NODE references a Volatile_Full_Access entity. This is /* Return true if GNAT_NODE references a Volatile_Full_Access entity. This is
modeled on the Is_VFA_Object predicate of the front-end, but additionally modeled on the Is_Volatile_Full_Access_Object predicate of the front-end,
handles explicit dereferences. */ but additionally handles explicit dereferences. */
static bool static bool
node_is_volatile_full_access (Node_Id gnat_node) node_is_volatile_full_access (Node_Id gnat_node)
......
...@@ -1358,19 +1358,13 @@ package body Sem_Ch8 is ...@@ -1358,19 +1358,13 @@ package body Sem_Ch8 is
end if; end if;
-- The entity of the renaming declaration needs to reflect whether the -- The entity of the renaming declaration needs to reflect whether the
-- renamed object is volatile. Is_Volatile is set if the renamed object -- renamed object is atomic, independent, volatile or VFA. These flags
-- is volatile in the RM legality sense. -- are set on the renamed object in the RM legality sense.
Set_Is_Atomic (Id, Is_Atomic_Object (Nam));
Set_Is_Independent (Id, Is_Independent_Object (Nam));
Set_Is_Volatile (Id, Is_Volatile_Object (Nam)); Set_Is_Volatile (Id, Is_Volatile_Object (Nam));
Set_Is_Volatile_Full_Access (Id, Is_Volatile_Full_Access_Object (Nam));
-- Also copy settings of Atomic/Independent/Volatile_Full_Access
if Is_Entity_Name (Nam) then
Set_Is_Atomic (Id, Is_Atomic (Entity (Nam)));
Set_Is_Independent (Id, Is_Independent (Entity (Nam)));
Set_Is_Volatile_Full_Access (Id,
Is_Volatile_Full_Access (Entity (Nam)));
end if;
-- Treat as volatile if we just set the Volatile flag -- Treat as volatile if we just set the Volatile flag
......
...@@ -1531,11 +1531,7 @@ package Sem_Util is ...@@ -1531,11 +1531,7 @@ package Sem_Util is
function Is_Atomic_Object (N : Node_Id) return Boolean; function Is_Atomic_Object (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a reference to an atomic -- Determine whether arbitrary node N denotes a reference to an atomic
-- object as per Ada RM C.6(7) and the crucial remark in C.6(8). -- object as per RM C.6(7) and the crucial remark in RM C.6(8).
function Is_Atomic_Object_Entity (Id : Entity_Id) return Boolean;
-- Determine whether arbitrary entity Id denotes an atomic object as per
-- Ada RM C.6(7).
function Is_Atomic_Or_VFA_Object (N : Node_Id) return Boolean; function Is_Atomic_Or_VFA_Object (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a reference to an object -- Determine whether arbitrary node N denotes a reference to an object
...@@ -1749,6 +1745,10 @@ package Sem_Util is ...@@ -1749,6 +1745,10 @@ package Sem_Util is
-- Determine whether arbitrary declaration Decl denotes a generic package, -- Determine whether arbitrary declaration Decl denotes a generic package,
-- a generic subprogram or a generic body. -- a generic subprogram or a generic body.
function Is_Independent_Object (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a reference to an independent
-- object as per RM C.6(8).
function Is_Inherited_Operation (E : Entity_Id) return Boolean; function Is_Inherited_Operation (E : Entity_Id) return Boolean;
-- E is a subprogram. Return True is E is an implicit operation inherited -- E is a subprogram. Return True is E is an implicit operation inherited
-- by a derived type declaration. -- by a derived type declaration.
...@@ -1996,7 +1996,7 @@ package Sem_Util is ...@@ -1996,7 +1996,7 @@ package Sem_Util is
function Is_Subcomponent_Of_Atomic_Object (N : Node_Id) return Boolean; function Is_Subcomponent_Of_Atomic_Object (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a reference to a subcomponent -- Determine whether arbitrary node N denotes a reference to a subcomponent
-- of an atomic object as per Ada RM C.6(7). -- of an atomic object as per RM C.6(7).
function Is_Subprogram_Contract_Annotation (Item : Node_Id) return Boolean; function Is_Subprogram_Contract_Annotation (Item : Node_Id) return Boolean;
-- Determine whether aspect specification or pragma Item is one of the -- Determine whether aspect specification or pragma Item is one of the
...@@ -2095,16 +2095,20 @@ package Sem_Util is ...@@ -2095,16 +2095,20 @@ package Sem_Util is
-- Initialize/Adjust/Finalize subprogram does not override the inherited -- Initialize/Adjust/Finalize subprogram does not override the inherited
-- one. -- one.
function Is_Volatile_Full_Access_Object (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a reference to an object
-- which is Volatile_Full_Access.
function Is_Volatile_Function (Func_Id : Entity_Id) return Boolean; function Is_Volatile_Function (Func_Id : Entity_Id) return Boolean;
-- Determine whether [generic] function Func_Id is subject to enabled -- Determine whether [generic] function Func_Id is subject to enabled
-- pragma Volatile_Function. Protected functions are treated as volatile -- pragma Volatile_Function. Protected functions are treated as volatile
-- (SPARK RM 7.1.2). -- (SPARK RM 7.1.2).
function Is_Volatile_Object (N : Node_Id) return Boolean; function Is_Volatile_Object (N : Node_Id) return Boolean;
-- Determines if the given node denotes an volatile object in the sense of -- Determine whether arbitrary node N denotes a reference to a volatile
-- the legality checks described in RM C.6(12). Note that the test here is -- object as per RM C.6(8). Note that the test here is for something that
-- for something actually declared as volatile, not for an object that gets -- is actually declared as volatile, not for an object that gets treated
-- treated as volatile (see Einfo.Treat_As_Volatile). -- as volatile (see Einfo.Treat_As_Volatile).
generic generic
with procedure Handle_Parameter (Formal : Entity_Id; Actual : Node_Id); with procedure Handle_Parameter (Formal : Entity_Id; Actual : Node_Id);
......
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