* [Ada] Suppress Initialize_Scalars for Persistent_BSS
@ 2019-08-20 9:51 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2019-08-20 9:51 UTC (permalink / raw)
To: gcc-patches; +Cc: Bob Duff
[-- Attachment #1: Type: text/plain, Size: 698 bytes --]
If a variable has pragma Persistent_BSS, the compiler now automatically
suppresses implicit initializations caused by Initialize_Scalars and
Normalize_Scalars. Variables with Persistent_BSS cannot be initialized,
and previously a pragma Suppress_Initialization was required before the
pragma Persistent_BSS.
Tested on x86_64-pc-linux-gnu, committed on trunk
2019-08-20 Bob Duff <duff@adacore.com>
gcc/ada/
* sem_prag.adb (Persistent_BSS): If an initialization is present
because of Initialize_Scalars or Normalize_Scalars, generate an
implicit pragma Suppress_Initialization to remove that, because
initialization is not allowed for these variables. Other
initializations remain illegal.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1596 bytes --]
--- gcc/ada/sem_prag.adb
+++ gcc/ada/sem_prag.adb
@@ -21092,8 +21092,24 @@ package body Sem_Prag is
Decl := Parent (Ent);
if Present (Expression (Decl)) then
- Error_Pragma_Arg
- ("object for pragma% cannot have initialization", Arg1);
+ -- Variables in Persistent_BSS cannot be initialized, so
+ -- turn off any initialization that might be caused by
+ -- pragmas Initialize_Scalars or Normalize_Scalars.
+
+ if Kill_Range_Check (Expression (Decl)) then
+ Prag :=
+ Make_Pragma (Loc,
+ Name_Suppress_Initialization,
+ Pragma_Argument_Associations => New_List (
+ Make_Pragma_Argument_Association (Loc,
+ Expression => New_Occurrence_Of (Ent, Loc))));
+ Insert_Before (N, Prag);
+ Analyze (Prag);
+
+ else
+ Error_Pragma_Arg
+ ("object for pragma% cannot have initialization", Arg1);
+ end if;
end if;
if not Is_Potentially_Persistent_Type (Etype (Ent)) then
@@ -21104,7 +21120,7 @@ package body Sem_Prag is
Prag :=
Make_Linker_Section_Pragma
- (Ent, Sloc (N), ".persistent.bss");
+ (Ent, Loc, ".persistent.bss");
Insert_After (N, Prag);
Analyze (Prag);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-08-20 9:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 9:51 [Ada] Suppress Initialize_Scalars for Persistent_BSS Pierre-Marie de Rodat
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).