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] Inheritance of representation aspects at freezing point


The test presented below deals with the aspect Volatile. Indeed it's illegal to
instantiate non-volatile formal object with volatile actual.

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

package Volatile is
   type Volatile is tagged record
      R : Integer;
   end record with Volatile;  --  Volatile

   type Der_Volatile is new Volatile with record
      R2 : Integer;
   end record;  --  Volatile by inheritance

   generic
      Non_Formal_Object : in out Integer;
   package Non_Volatile_Formal is end;

   DerVol : Der_Volatile;

   package Error is new Non_Volatile_Formal (DerVol.R2);
   --  instantiation error since the actual DerVol.R2 is volatile whereas the
   --  formal Non_Formal_Object is non-volatile.
end Volatile;

-----------------
-- Compilation --
-----------------

$ gcc -c -gnat12 volatile.ads
volatile.ads:16:52: cannot instantiate non-volatile formal object with volatile actual

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

2012-08-06  Vincent Pucci  <pucci@adacore.com>

	* freeze.adb (Freeze_Entity): Inherit_Aspects_At_Freeze_Point
	calls added for derived types and subtypes.
	* sem_aux.adb, sem_aux.ads (Get_Rep_Item, Get_Rep_Pragma,
	Has_Rep_Pragma): New routines.
	* sem_ch13.ads (Inherit_Aspects_At_Freeze_Point): New routine.
	* sem_ch13.adb (Analyze_Aspect_Specifications): Error message
	for aspect Lock_Free fixed.
	(Inherits_Aspects_At_Freeze_Point): New routine.
	* sem_ch3.adb: Several flag settings removed since inheritance
	of aspects must be performed at freeze point.

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]