Skip to content
Snippets Groups Projects
Commit cad2744c authored by Eric Botcazou's avatar Eric Botcazou Committed by Marc Poulhiès
Browse files

ada: Factor out implementation of default initialization for objects

As written down in a comment, "There is a *huge* amount of code duplication"
in the implementation of default initializaion for objects in the front-end,
between the (static) declaration case and the dynamic allocation case.

This change factors out the implementation of the (static) declaration case
and uses it for the dynamic allocation case, with the following benefits:

  1. getting rid of the duplication and reducing total line count,

  2. bringing optimizations implemented for the (static) declaration case
     to the dynamic allocation case,

  3. performing the missing abort deferral prescribed by RM 9.8(9) in the
     dynamic allocation case.

gcc/ada/

	* exp_aggr.adb (Build_Record_Aggr_Code): Replace reference to
	Build_Task_Allocate_Block_With_Init_Stmts in comment with reference
	to Build_Task_Allocate_Block.
	(Convert_Aggr_In_Allocator): Likewise for the call in the code.
	* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.
	* exp_ch3.ads: Alphabetize clauses.
	(Build_Default_Initialization): New function declaration.
	(Build_Default_Simple_Initialization): Likewise.
	(Build_Initialization_Call): Add Target_Ref parameter with default.
	* exp_ch3.adb (Build_Default_Initialization): New function extracted
	from...
	(Build_Default_Simple_Initialization): Likewise.
	(Build_Initialization_Call): Add Target_Ref parameter with default.
	(Expand_N_Object_Declaration): ...here.
	(Default_Initialize_Object): Call Build_Default_Initialization and
	Build_Default_Simple_Initialization.
	* exp_ch4.adb (Expand_Allocator_Expression): Minor comment tweaks.
	(Expand_N_Allocator): Call Build_Default_Initialization and
	Build_Default_Simple_Initialization to implement the default
	initialization of the allocated object.
	* exp_ch9.ads (Build_Task_Allocate_Block): Delete.
	(Build_Task_Allocate_Block_With_Init_Stmts): Rename into...
	(Build_Task_Allocate_Block): ...this.
	* exp_ch9.adb: Remove clauses for Exp_Tss.
	(Build_Task_Allocate_Block): Delete.
	(Build_Task_Allocate_Block_With_Init_Stmts): Rename into...
	(Build_Task_Allocate_Block): ...this.
	* exp_util.adb (Build_Allocate_Deallocate_Proc): Remove unnecessary
	initialization expression, adjust commentary and replace early exit
	with assertion.
	* sem_ch4.adb (Analyze_Allocator): In the null-exclusion case, call
	Apply_Compile_Time_Constraint_Error to insert the raise.
parent 82177247
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment