summaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch4.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/exp_ch4.adb')
-rw-r--r--gcc/ada/exp_ch4.adb77
1 files changed, 66 insertions, 11 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 87e02d0e1ee..d2f0668873e 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -591,8 +591,7 @@ package body Exp_Ch4 is
-- 1) Get access to the allocated object
Rewrite (N,
- Make_Explicit_Dereference (Loc,
- Relocate_Node (N)));
+ Make_Explicit_Dereference (Loc, Relocate_Node (N)));
Set_Etype (N, Etyp);
Set_Analyzed (N);
@@ -2615,12 +2614,7 @@ package body Exp_Ch4 is
-- Result of the concatenation (of type Ityp)
Actions : constant List_Id := New_List;
- -- Collect actions to be inserted if Save_Space is False
-
- Save_Space : Boolean;
- pragma Warnings (Off, Save_Space);
- -- Set to True if we are saving generated code space by calling routines
- -- in packages System.Concat_n.
+ -- Collect actions to be inserted
Known_Non_Null_Operand_Seen : Boolean;
-- Set True during generation of the assignments of operands into
@@ -4472,6 +4466,15 @@ package body Exp_Ch4 is
-- Insert explicit dereference call for the checked storage pool case
Insert_Dereference_Action (Prefix (N));
+
+ -- If the type is an Atomic type for which Atomic_Sync is enabled, then
+ -- we set the atomic sync flag.
+
+ if Is_Atomic (Etype (N))
+ and then not Atomic_Synchronization_Disabled (Etype (N))
+ then
+ Activate_Atomic_Synchronization (N);
+ end if;
end Expand_N_Explicit_Dereference;
--------------------------------------
@@ -5245,6 +5248,7 @@ package body Exp_Ch4 is
Typ : constant Entity_Id := Etype (N);
P : constant Node_Id := Prefix (N);
T : constant Entity_Id := Etype (P);
+ Atp : Entity_Id;
begin
-- A special optimization, if we have an indexed component that is
@@ -5290,6 +5294,9 @@ package body Exp_Ch4 is
if Is_Access_Type (T) then
Insert_Explicit_Dereference (P);
Analyze_And_Resolve (P, Designated_Type (T));
+ Atp := Designated_Type (T);
+ else
+ Atp := T;
end if;
-- Generate index and validity checks
@@ -5300,6 +5307,17 @@ package body Exp_Ch4 is
Apply_Subscript_Validity_Checks (N);
end if;
+ -- If selecting from an array with atomic components, and atomic sync
+ -- is not suppressed for this array type, set atomic sync flag.
+
+ if (Has_Atomic_Components (Atp)
+ and then not Atomic_Synchronization_Disabled (Atp))
+ or else (Is_Atomic (Typ)
+ and then not Atomic_Synchronization_Disabled (Typ))
+ then
+ Activate_Atomic_Synchronization (N);
+ end if;
+
-- All done for the non-packed case
if not Is_Packed (Etype (Prefix (N))) then
@@ -7869,9 +7887,6 @@ package body Exp_Ch4 is
-- Expand_N_Selected_Component --
---------------------------------
- -- If the selector is a discriminant of a concurrent object, rewrite the
- -- prefix to denote the corresponding record type.
-
procedure Expand_N_Selected_Component (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Par : constant Node_Id := Parent (N);
@@ -8175,6 +8190,46 @@ package body Exp_Ch4 is
Rewrite (N, New_N);
Analyze (N);
end if;
+
+ -- Set Atomic_Sync_Required if necessary for atomic component
+
+ if Nkind (N) = N_Selected_Component then
+ declare
+ E : constant Entity_Id := Entity (Selector_Name (N));
+ Set : Boolean;
+
+ begin
+ -- If component is atomic, but type is not, setting depends on
+ -- disable/enable state for the component.
+
+ if Is_Atomic (E) and then not Is_Atomic (Etype (E)) then
+ Set := not Atomic_Synchronization_Disabled (E);
+
+ -- If component is not atomic, but its type is atomic, setting
+ -- depends on disable/enable state for the type.
+
+ elsif not Is_Atomic (E) and then Is_Atomic (Etype (E)) then
+ Set := not Atomic_Synchronization_Disabled (Etype (E));
+
+ -- If both component and type are atomic, we disable if either
+ -- component or its type have sync disabled.
+
+ elsif Is_Atomic (E) and then Is_Atomic (Etype (E)) then
+ Set := (not Atomic_Synchronization_Disabled (E))
+ and then
+ (not Atomic_Synchronization_Disabled (Etype (E)));
+
+ else
+ Set := False;
+ end if;
+
+ -- Set flag if required
+
+ if Set then
+ Activate_Atomic_Synchronization (N);
+ end if;
+ end;
+ end if;
end Expand_N_Selected_Component;
--------------------