public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Static intialization with pragma Linker_Section
@ 2017-04-25  9:47 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2017-04-25  9:47 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bob Duff

[-- Attachment #1: Type: text/plain, Size: 480 bytes --]

This patch is an improvement that causes an array object that has a
pragma Linker_Section with a compile-time-known initial value to be
statically initialized in place in the appropriate section.

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

2017-04-25  Bob Duff  <duff@adacore.com>

	* freeze.adb (Freeze_Object_Declaration): Do
	not Remove_Side_Effects if there is a pragma Linker_Section,
	because in that case we want static initialization in the
	appropriate section.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 900 bytes --]

Index: freeze.adb
===================================================================
--- freeze.adb	(revision 247155)
+++ freeze.adb	(working copy)
@@ -3197,12 +3197,15 @@
 
          --  Similar processing is needed for aspects that may affect
          --  object layout, like Alignment, if there is an initialization
-         --  expression.
+         --  expression. We don't do this if there is a pragma Linker_Section,
+         --  because it would prevent the back end from statically initializing
+         --  the object; we don't want elaboration code in that case.
 
          if Has_Delayed_Aspects (E)
            and then Expander_Active
            and then Is_Array_Type (Etype (E))
            and then Present (Expression (Parent (E)))
+           and then No (Linker_Section_Pragma (E))
          then
             declare
                Decl : constant Node_Id := Parent (E);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-25  9:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-25  9:47 [Ada] Static intialization with pragma Linker_Section 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).