Commit ec77b144 by Hristian Kirtchev Committed by Arnaud Charlet

sem_prag.adb (Analyze_Global_Item): Move the check concerning the use of…

sem_prag.adb (Analyze_Global_Item): Move the check concerning the use of volatile objects as global items in a...

2014-02-24  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_prag.adb (Analyze_Global_Item): Move the check concerning
	the use of volatile objects as global items in a function to
	the variable related checks section.
	* sem_util.adb (Async_Readers_Enabled): Directly call
	Has_Enabled_Property.
	(Async_Writers_Enabled): Directly call Has_Enabled_Property.
	(Effective_Reads_Enabled): Directly call Has_Enabled_Property.
	(Effective_Writes_Enabled): Directly call Has_Enabled_Property.
	(Has_Enabled_Property): Rename formal parameter State_Id to Item_Id.
	Update the comment on usage. State_Has_Enabled_Property how handles
	the original logic of the routine. Add processing for variables.
	(State_Has_Enabled_Property): New routine.
	(Variable_Has_Enabled_Property): New routine.

From-SVN: r208077
parent 32bba3c9
2014-02-24 Hristian Kirtchev <kirtchev@adacore.com>
* sem_prag.adb (Analyze_Global_Item): Move the check concerning
the use of volatile objects as global items in a function to
the variable related checks section.
* sem_util.adb (Async_Readers_Enabled): Directly call
Has_Enabled_Property.
(Async_Writers_Enabled): Directly call Has_Enabled_Property.
(Effective_Reads_Enabled): Directly call Has_Enabled_Property.
(Effective_Writes_Enabled): Directly call Has_Enabled_Property.
(Has_Enabled_Property): Rename formal parameter State_Id to Item_Id.
Update the comment on usage. State_Has_Enabled_Property how handles
the original logic of the routine. Add processing for variables.
(State_Has_Enabled_Property): New routine.
(Variable_Has_Enabled_Property): New routine.
2014-02-24 Robert Dewar <dewar@adacore.com> 2014-02-24 Robert Dewar <dewar@adacore.com>
* sinfo.ads, sem_ch12.adb, sem_res.adb, sem_ch4.adb, par-ch12.adb: * sinfo.ads, sem_ch12.adb, sem_res.adb, sem_ch4.adb, par-ch12.adb:
......
...@@ -2060,16 +2060,28 @@ package body Sem_Prag is ...@@ -2060,16 +2060,28 @@ package body Sem_Prag is
-- Variable related checks -- Variable related checks
else elsif Is_SPARK_Volatile_Object (Item_Id) then
-- A volatile object cannot appear as a global item of a
-- function. This check is only relevant when SPARK_Mode is
-- on as it is not a standard Ada legality rule.
if SPARK_Mode = On
and then Ekind_In (Spec_Id, E_Function, E_Generic_Function)
then
Error_Msg_NE
("volatile object & cannot act as global item of a "
& "function (SPARK RM 7.1.3(9))", Item, Item_Id);
return;
-- A volatile object with property Effective_Reads set to -- A volatile object with property Effective_Reads set to
-- True must have mode Output or In_Out. -- True must have mode Output or In_Out.
if Is_SPARK_Volatile_Object (Item_Id) elsif Effective_Reads_Enabled (Item_Id)
and then Effective_Reads_Enabled (Item_Id)
and then Global_Mode = Name_Input and then Global_Mode = Name_Input
then then
Error_Msg_NE Error_Msg_NE
("volatile item & with property Effective_Reads must " ("volatile object & with property Effective_Reads must "
& "have mode In_Out or Output (SPARK RM 7.1.3(11))", & "have mode In_Out or Output (SPARK RM 7.1.3(11))",
Item, Item_Id); Item, Item_Id);
return; return;
...@@ -2100,19 +2112,6 @@ package body Sem_Prag is ...@@ -2100,19 +2112,6 @@ package body Sem_Prag is
Check_Mode_Restriction_In_Enclosing_Context (Item, Item_Id); Check_Mode_Restriction_In_Enclosing_Context (Item, Item_Id);
end if; end if;
-- A volatile object cannot appear as a global item of a function.
-- This check is only relevant when SPARK_Mode is on as it is not
-- a standard Ada legality rule.
if SPARK_Mode = On
and then Is_SPARK_Volatile_Object (Item)
and then Ekind_In (Spec_Id, E_Function, E_Generic_Function)
then
Error_Msg_NE
("volatile object & cannot act as global item of a function "
& "(SPARK RM 7.1.3(9))", Item, Item_Id);
end if;
-- The same entity might be referenced through various way. Check -- The same entity might be referenced through various way. Check
-- the entity of the item rather than the item itself. -- the entity of the item rather than the item itself.
......
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