From: Arnaud Charlet <charlet@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ed Schonberg <schonberg@adacore.com>
Subject: [Ada] Concatenation and initialize_scalars
Date: Mon, 21 Jun 2010 13:38:00 -0000 [thread overview]
Message-ID: <20100621132638.GA15894@adacore.com> (raw)
[-- 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
reply other threads:[~2010-06-21 13:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100621132638.GA15894@adacore.com \
--to=charlet@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=schonberg@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).