aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_util.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2017-01-23 12:51:26 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2017-01-23 12:51:26 +0100
commit0f83b0444cf59c7d73fd870e71f6cac3c69a134e (patch)
tree3cd396db2fefb65be70f35f769705e23a6e844cb /gcc/ada/sem_util.adb
parent52b70b1bef33b0a6a339c631b084cf030bc501e9 (diff)
downloadgcc-0f83b0444cf59c7d73fd870e71f6cac3c69a134e.zip
gcc-0f83b0444cf59c7d73fd870e71f6cac3c69a134e.tar.gz
gcc-0f83b0444cf59c7d73fd870e71f6cac3c69a134e.tar.bz2
[multiple changes]
2017-01-23 Gary Dismukes <dismukes@adacore.com> * a-calend.adb, prep.adb, debug.adb, prj.ads, prepcomp.adb, exp_disp.adb, s-imgrea.adb, g-socket.adb, g-socket.ads, sem_ch13.adb, prj-tree.ads: Minor spelling change for consistency (behaviour -> behavior). 2017-01-23 Ed Schonberg <schonberg@adacore.com> * scng.adb (Scan): Use Ada version Ada_2020 to flag use of Target_Name. * par-ch4.adb (P_Primary): Ditto. * opt.ads: Add Ada_2020 (optimistically) to enumeration list of Ada_Version_Type. * switch-c.adb (Scan_Front_End_Switches): Recognize -gnat2020 for new Ada version Ada_2020. 2017-01-23 Hristian Kirtchev <kirtchev@adacore.com> * exp_attr.adb (Expand_Loop_Entry_Attribute): Force the generation of a nominal type for the constant which captures the value of the attribute prefix. Various clean ups. * sem_attr.adb (Analyze_Attribute): Clean up the processing of 'Loop_Entry. 2017-01-23 Yannick Moy <moy@adacore.com> * sem_util.adb (Has_Enabled_Property): Treat protected objects and variables differently from other variables. From-SVN: r244787
Diffstat (limited to 'gcc/ada/sem_util.adb')
-rw-r--r--gcc/ada/sem_util.adb64
1 files changed, 63 insertions, 1 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 694e112..5958d42 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -9118,6 +9118,10 @@ package body Sem_Util is
(Item_Id : Entity_Id;
Property : Name_Id) return Boolean
is
+ function Protected_Object_Has_Enabled_Property return Boolean;
+ -- Determine whether a protected object denoted by Item_Id has the
+ -- property enabled.
+
function State_Has_Enabled_Property return Boolean;
-- Determine whether a state denoted by Item_Id has the property enabled
@@ -9125,6 +9129,44 @@ package body Sem_Util is
-- Determine whether a variable denoted by Item_Id has the property
-- enabled.
+ -------------------------------------------
+ -- Protected_Object_Has_Enabled_Property --
+ -------------------------------------------
+
+ function Protected_Object_Has_Enabled_Property return Boolean is
+ Constits : constant Elist_Id := Part_Of_Constituents (Item_Id);
+ Constit_Elmt : Elmt_Id;
+ Constit_Id : Entity_Id;
+
+ begin
+ -- Protected objects always have the properties Async_Readers and
+ -- Async_Writers. (SPARK RM 7.1.2(16))
+
+ if Property = Name_Async_Readers
+ or else Property = Name_Async_Writers
+ then
+ return True;
+
+ -- Protected objects that have Part_Of components also inherit
+ -- their properties Effective_Reads and Effective_Writes. (SPARK
+ -- RM 7.1.2(16))
+
+ elsif Present (Constits) then
+ Constit_Elmt := First_Elmt (Constits);
+ while Present (Constit_Elmt) loop
+ Constit_Id := Node (Constit_Elmt);
+
+ if Has_Enabled_Property (Constit_Id, Property) then
+ return True;
+ end if;
+
+ Next_Elmt (Constit_Elmt);
+ end loop;
+ end if;
+
+ return False;
+ end Protected_Object_Has_Enabled_Property;
+
--------------------------------
-- State_Has_Enabled_Property --
--------------------------------
@@ -9302,7 +9344,19 @@ package body Sem_Util is
-- The implicit case lacks all property pragmas
elsif No (AR) and then No (AW) and then No (ER) and then No (EW) then
- return True;
+
+ -- A variable of a protected type only has the properties
+ -- Async_Readers and Async_Writers. It cannot have Part_Of
+ -- components (only protected objects can), hence it cannot
+ -- inherit their properties Effective_Reads and Effective_Writes.
+ -- (SPARK RM 7.1.2(16))
+
+ if Is_Protected_Type (Etype (Item_Id)) then
+ return Property = Name_Async_Readers
+ or else Property = Name_Async_Writers;
+ else
+ return True;
+ end if;
else
return False;
@@ -9321,6 +9375,14 @@ package body Sem_Util is
elsif Ekind (Item_Id) = E_Variable then
return Variable_Has_Enabled_Property;
+ -- By default, protected objects only have the properties Async_Readers
+ -- and Async_Writers. If they have Part_Of components, they also inherit
+ -- their properties Effective_Reads and Effective_Writes. (SPARK RM
+ -- 7.1.2(16))
+
+ elsif Ekind (Item_Id) = E_Protected_Object then
+ return Protected_Object_Has_Enabled_Property;
+
-- Otherwise a property is enabled when the related item is effectively
-- volatile.