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 abort deferral on controlled aggregate component assignment


This patch adds an abort defer / undefer pair around the initialization
statements of a controlled aggregate component as dictated by 9.8 11.

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

--  aggregates.ads

with Ada.Finalization; use Ada.Finalization;

package Aggregates is
   type Ctrl is new Controlled with null record;

   Ctrl_Obj : constant Ctrl := (Controlled with null record);

   type Arr is array (1 .. 3) of Ctrl;

   Arr_Obj_1 : constant Arr := (others => Ctrl_Obj);
   Arr_Obj_2 : constant Arr := (others => (Controlled with null record));

   type Rec is record
      Comp : Ctrl;
   end record;

   Rec_Obj_1 : constant Rec := (Comp => Ctrl_Obj);
   Rec_Obj_2 : constant Rec := (Comp => (Controlled with null record));
end Aggregates;

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

$ gcc -c -gnatDG aggregates.ads
$ line=$(grep -n "arr_obj_1 : constant" aggregates.ads.dg | cut -f1 -d:)
$ tail -n +$line aggregates.ads.dg | head -n 20 | grep "abort_" | sed "s/^ *//"
system__soft_links__abort_defer.all;
system__standard_library__abort_undefer_direct;

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

2016-07-06  Hristian Kirtchev  <kirtchev@adacore.com>

	* exp_aggr.adb Remove with and use clauses for Exp_Ch11 and Inline.
	(Initialize_Array_Component): Protect the initialization
	statements in an abort defer / undefer block when the associated
	component is controlled.
	(Initialize_Record_Component): Protect the initialization statements
	in an abort defer / undefer block when the associated component is
	controlled.
	(Process_Transient_Component_Completion): Use Build_Abort_Undefer_Block
	to create an abort defer / undefer block.
	* exp_ch3.adb Remove with and use clauses for Exp_ch11 and Inline.
	(Default_Initialize_Object): Use Build_Abort_Undefer_Block to
	create an abort defer / undefer block.
	* exp_ch5.adb (Expand_N_Assignment_Statement): Mark an abort
	defer / undefer block as such.
	* exp_ch9.adb (Find_Enclosing_Context): Do not consider an abort
	defer / undefer block as a suitable context for an activation
	chain or a master.
	* exp_util.adb Add with and use clauses for Exp_Ch11.
	(Build_Abort_Undefer_Block): New routine.
	* exp_util.ads (Build_Abort_Undefer_Block): New routine.
	* sinfo.adb (Is_Abort_Block): New routine.
	(Set_Is_Abort_Block): New routine.
	* sinfo.ads New attribute Is_Abort_Block along with occurrences
	in nodes.
	(Is_Abort_Block): New routine along with pragma Inline.
	(Set_Is_Abort_Block): New routine along with pragma Inline.

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]