From patchwork Mon Jun 21 13:26:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Ada] Concatenation and initialize_scalars Date: Mon, 21 Jun 2010 03:26:38 -0000 From: Arnaud Charlet X-Patchwork-Id: 56312 Message-Id: <20100621132638.GA15894@adacore.com> To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg In certain contexts, a concatenation operation is expanded into an object declaration followed by an assignment. The object declaration must not be initialized when Initialize_Scalars is enabled. The following must compile quietly: pragma Initialize_Scalars; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure P is type String_Access_T is access String; task type Task_T (Name : String_Access_T); task body Task_T is begin null; end; type Task_Access_T is access Task_T; procedure Nested (T_Name : Unbounded_String) is T_Ptr : Task_Access_T; begin T_Ptr := new Task_T (Name => new String'("." & To_String (T_Name))); end; begin null; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-21 Ed Schonberg * exp_ch4.adb (Expand_Concatenate): If an object declaration is created to hold the result, indicate that the target of the declaration does not need an initialization, to prevent spurious errors when Initialize_Scalars is enabled. Index: exp_ch4.adb =================================================================== --- exp_ch4.adb (revision 161073) +++ exp_ch4.adb (working copy) @@ -2827,8 +2827,11 @@ package body Exp_Ch4 is Insert_Actions (Cnode, Actions, Suppress => All_Checks); -- Now we construct an array object with appropriate bounds + -- The target is marked as internal, to prevent useless initialization + -- when Initialize_Scalars is enabled. Ent := Make_Temporary (Loc, 'S'); + Set_Is_Internal (Ent); -- If the bound is statically known to be out of range, we do not want -- to abort, we want a warning and a runtime constraint error. Note that