aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_res.adb
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2014-08-04 13:17:46 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2014-08-04 15:17:46 +0200
commitc2a2dbcc6ba197d3e6921ac220a097ac617c1493 (patch)
treede160f44f4e92149fac97ee73db9bac04386ffea /gcc/ada/sem_res.adb
parent6cf7eae6899491ba8759f8da6a86c8e27073d6f9 (diff)
downloadgcc-c2a2dbcc6ba197d3e6921ac220a097ac617c1493.zip
gcc-c2a2dbcc6ba197d3e6921ac220a097ac617c1493.tar.gz
gcc-c2a2dbcc6ba197d3e6921ac220a097ac617c1493.tar.bz2
aspects.ads, [...]: Add entries for aspect Obsolescent.
2014-08-04 Robert Dewar <dewar@adacore.com> * aspects.ads, aspects.adb: Add entries for aspect Obsolescent. * gnat_rm.texi: Add documentation for aspect Obsolescent. * sem_ch13.adb (Analyze_Aspect_Specifications): Implement aspect Obsolescent. (Check_Aspect_At_Freeze_Point): Add dummy entry for pragma Obsolescent. * s-osprim-mingw.adb: Minor reformatting. * sem_res.adb (Is_Atomic_Ref_With_Address): New function (Resolve_Indexed_Component): Rework warnings for non-atomic access (Resolve_Selected_Component): Add warnings for non-atomic access. From-SVN: r213588
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r--gcc/ada/sem_res.adb73
1 files changed, 51 insertions, 22 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 1594f23..f45e07e 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -128,6 +128,11 @@ package body Sem_Res is
-- for restriction No_Direct_Boolean_Operators. This procedure also handles
-- the style check for Style_Check_Boolean_And_Or.
+ function Is_Atomic_Ref_With_Address (N : Node_Id) return Boolean;
+ -- N is either an indexed component or a selected component. This function
+ -- returns true if the prefix refers to an object that has an address
+ -- clause (the case in which we may want to issue a warning).
+
function Is_Definite_Access_Type (E : Entity_Id) return Boolean;
-- Determine whether E is an access type declared by an access declaration,
-- and not an (anonymous) allocator type.
@@ -1131,6 +1136,29 @@ package body Sem_Res is
end if;
end Check_Parameterless_Call;
+ --------------------------------
+ -- Is_Atomic_Ref_With_Address --
+ --------------------------------
+
+ function Is_Atomic_Ref_With_Address (N : Node_Id) return Boolean is
+ Pref : constant Node_Id := Prefix (N);
+
+ begin
+ if not Is_Entity_Name (Pref) then
+ return False;
+
+ else
+ declare
+ Pent : constant Entity_Id := Entity (Pref);
+ Ptyp : constant Entity_Id := Etype (Pent);
+ begin
+ return not Is_Access_Type (Ptyp)
+ and then (Is_Atomic (Ptyp) or else Is_Atomic (Pent))
+ and then Present (Address_Clause (Pent));
+ end;
+ end if;
+ end Is_Atomic_Ref_With_Address;
+
-----------------------------
-- Is_Definite_Access_Type --
-----------------------------
@@ -7973,19 +8001,20 @@ package body Sem_Res is
Eval_Indexed_Component (N);
end if;
- -- If the array type is atomic, and is packed, and we are in a left side
- -- context, then this is worth a warning, since we have a situation
- -- where the access to the component may cause extra read/writes of
- -- the atomic array object, which could be considered unexpected.
+ -- If the array type is atomic, and the component is not atomic, then
+ -- this is worth a warning, since we have a situation where the access
+ -- to the component may cause extra read/writes of the atomic array
+ -- object, or partial word accesses, which could be unexpected.
if Nkind (N) = N_Indexed_Component
- and then (Is_Atomic (Array_Type)
- or else (Is_Entity_Name (Prefix (N))
- and then Is_Atomic (Entity (Prefix (N)))))
- and then Is_Bit_Packed_Array (Array_Type)
- and then Is_LHS (N) = Yes
+ and then Is_Atomic_Ref_With_Address (N)
+ and then not (Has_Atomic_Components (Array_Type)
+ or else (Is_Entity_Name (Prefix (N))
+ and then Has_Atomic_Components
+ (Entity (Prefix (N)))))
+ and then not Is_Atomic (Component_Type (Array_Type))
then
- Error_Msg_N ("??assignment to component of packed atomic array",
+ Error_Msg_N ("??access to non-atomic component of atomic array",
Prefix (N));
Error_Msg_N ("??\may cause unexpected accesses to atomic object",
Prefix (N));
@@ -9293,7 +9322,7 @@ package body Sem_Res is
procedure Resolve_Selected_Component (N : Node_Id; Typ : Entity_Id) is
Comp : Entity_Id;
Comp1 : Entity_Id := Empty; -- prevent junk warning
- P : constant Node_Id := Prefix (N);
+ P : constant Node_Id := Prefix (N);
S : constant Node_Id := Selector_Name (N);
T : Entity_Id := Etype (P);
I : Interp_Index;
@@ -9470,22 +9499,22 @@ package body Sem_Res is
-- Note: No Eval processing is required, because the prefix is of a
-- record type, or protected type, and neither can possibly be static.
- -- If the array type is atomic, and is packed, and we are in a left side
- -- context, then this is worth a warning, since we have a situation
- -- where the access to the component may cause extra read/writes of the
- -- atomic array object, which could be considered unexpected.
+ -- If the record type is atomic, and the component is non-atomic, then
+ -- this is worth a warning, since we have a situation where the access
+ -- to the component may cause extra read/writes of the atomic array
+ -- object, or partial word accesses, both of which may be unexpected.
if Nkind (N) = N_Selected_Component
- and then (Is_Atomic (T)
- or else (Is_Entity_Name (Prefix (N))
- and then Is_Atomic (Entity (Prefix (N)))))
- and then Is_Packed (T)
- and then Is_LHS (N) = Yes
+ and then Is_Atomic_Ref_With_Address (N)
+ and then not Is_Atomic (Entity (S))
+ and then not Is_Atomic (Etype (Entity (S)))
then
Error_Msg_N
- ("??assignment to component of packed atomic record", Prefix (N));
+ ("??access to non-atomic component of atomic record",
+ Prefix (N));
Error_Msg_N
- ("\??may cause unexpected accesses to atomic object", Prefix (N));
+ ("\??may cause unexpected accesses to atomic object",
+ Prefix (N));
end if;
Analyze_Dimension (N);