This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Reject the use of volatiles in assertion expressions


This patch corrects the trigger which determines the proper context of a
volatile object with enabled property Async_Writers or Effective_Reads.

------------
-- Source --
------------

--  assert_exprs.ads

package Assert_Exprs with SPARK_Mode is
   type T is new Integer with Volatile;

   procedure Error (Input : T; Output : out T)
     with Pre  => Input > 1,
          Post => Output = Input * 2;
end Assert_Exprs;

--  assert_exprs.adb

package body Assert_Exprs with SPARK_Mode is
   procedure Error (Input : T; Output : out T) is
   begin
      Output := Input * 2;
   end Error;
end Assert_Exprs;

----------------------------
-- Compilation and output --
----------------------------

$ gcc -c -gnata assert_exprs.adb
assert_exprs.adb:4:17: volatile object cannot appear in this context (SPARK RM
  7.1.3(13))
assert_exprs.ads:5:19: volatile object cannot appear in this context (SPARK RM
  7.1.3(13))
assert_exprs.ads:6:19: volatile object cannot appear in this context (SPARK RM
  7.1.3(13))
assert_exprs.ads:6:28: volatile object cannot appear in this context (SPARK RM
  7.1.3(13))

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-05-21  Hristian Kirtchev  <kirtchev@adacore.com>

	* freeze.adb (Freeze_Record_Type): Update the use of
	Is_SPARK_Volatile.
	* sem_ch3.adb (Analyze_Object_Contract): Update the use of
	Is_SPARK_Volatile.
	(Process_Discriminants): Update the use of Is_SPARK_Volatile.
	* sem_ch5.adb (Analyze_Iterator_Specification): Update the use
	of Is_SPARK_Volatile.
	(Analyze_Loop_Parameter_Specification):
	Update the use of Is_SPARK_Volatile.
	* sem_ch6.adb (Process_Formals): Catch an illegal use of an IN
	formal parameter when its type is volatile.
	* sem_prag.adb (Analyze_Global_Item): Update the use of
	Is_SPARK_Volatile.
	* sem_res.adb (Resolve_Entity_Name): Correct the guard which
	determines whether an entity is a volatile source SPARK object.
	* sem_util.adb (Has_Enabled_Property): Accout for external
	properties being set on objects other than abstract states
	and variables. An example would be a formal parameter.
	(Is_SPARK_Volatile): New routine.
	(Is_SPARK_Volatile_Object):
	Remove the entity-specific tests. Call routine Is_SPARK_Volatile
	when checking entities and/or types.
	* sem_util.ads (Is_SPARK_Volatile): New routine.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]