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 inheritance of pragma Default_Initial_Condition


This patch modifies the inheritance of all attributes related to pragma
Default_Initial_Condition to account for a case where the full view of
a private type derives from another private type.

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

--  parent.ads

package Parent is
   type Parent_Typ is private
     with Default_Initial_Condition => False;
private
   type Parent_Typ is null record;
end Parent;

--  derivation.ads

with Parent; use Parent;

package Derivation is
   type Derivation_Typ is private;
private
   type Derivation_Typ is new Parent_Typ;
end Derivation;

--  derivation_check.adb

with Ada.Assertions; use Ada.Assertions;
with Ada.Text_IO;    use Ada.Text_IO;
with Derivation;     use Derivation;

procedure Derivation_Check is
begin
   declare
      Obj : Derivation_Typ;
   begin
      Put_Line ("ERROR: Default_Initial_Condition not triggered");
   end;
exception
   when Assertion_Error =>
      Put_Line ("OK");
   when others          =>
      Put_Line ("ERROR: expected Assertion_Error");
end Derivation_Check;

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

$ gnatmake -q -gnata derivation_check.adb
$ ./derivation_check
OK

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

2014-10-17  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_ch3.adb (Build_Derived_Record_Type): Remove the propagation
	of all attributes related to pragma Default_Initial_Condition.
	(Build_Derived_Type): Propagation of all attributes related
	to pragma Default_Initial_Condition.
	(Process_Full_View): Account for the case where the full view derives
	from another private type and propagate the attributes related
	to pragma Default_Initial_Condition to the private view.
	(Propagate_Default_Init_Cond_Attributes): New routine.
	* sem_util.adb: Alphabetize various routines.
	(Build_Default_Init_Cond_Call): Use an unchecked type conversion
	when calling the default initial condition procedure of a private type.
	(Build_Default_Init_Cond_Procedure_Declaration): Prevent
	the generation of multiple default initial condition procedures.

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]