* [Ada] Concatenation and initialize_scalars
@ 2010-06-21 13:38 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2010-06-21 13:38 UTC (permalink / raw)
To: gcc-patches; +Cc: Ed Schonberg
[-- Attachment #1: Type: text/plain, Size: 1025 bytes --]
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 <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.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 694 bytes --]
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-06-21 13:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-21 13:38 [Ada] Concatenation and initialize_scalars Arnaud Charlet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).