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] Missing error on volatile return type of non-volatile function


This patch modifies the predicate which determines whether a function is
volatile to correctly recognize a protected function.

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

--  vol_func.ads

package Vol_Func with SPARK_Mode is
   protected type Prot is
   end Prot;

   type Vol_Typ is null record with Volatile;

   function F (X : Prot) return Vol_Typ;
   function G            return Vol_Typ;
end Vol_Func;

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

$ gcc -c vol_func.ads
vol_func.ads:7:16: nonvolatile function "F" cannot have a volatile parameter
vol_func.ads:7:33: nonvolatile function "F" cannot have a volatile return type
vol_func.ads:8:33: nonvolatile function "G" cannot have a volatile return type

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

2015-11-18  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_util.adb (Check_Nonvolatile_Function_Profile): Place the error
	message concerning the return type on the result definition.
	(Is_Volatile_Function): A function with a parameter of a protected
	type is a protected function if it is defined within a protected
	definition.

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]