[Ada] Concatenation and initialize_scalars
diff mbox

Message ID 20100621132638.GA15894@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet June 21, 2010, 1:26 p.m. UTC
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;
    T_Ptr := new Task_T (Name => new String'("." & To_String (T_Name)));


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

2010-06-21  Ed Schonberg  <schonberg@adacore.com>

	* 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.

diff mbox

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