aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2019-08-20 09:49:51 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-08-20 09:49:51 +0000
commit9740c2446478d5d1e85015f3d40402b8ca1b061a (patch)
treecacf682c71c78586d181e9209a1988913459fa0d
parente0ea5d16a80b1216387ba00c27ee2ea0e808ac42 (diff)
downloadgcc-9740c2446478d5d1e85015f3d40402b8ca1b061a.zip
gcc-9740c2446478d5d1e85015f3d40402b8ca1b061a.tar.gz
gcc-9740c2446478d5d1e85015f3d40402b8ca1b061a.tar.bz2
[Ada] Suppress Initialize_Scalars for Persistent_BSS
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. 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. From-SVN: r274732
-rw-r--r--gcc/ada/ChangeLog8
-rw-r--r--gcc/ada/sem_prag.adb22
2 files changed, 27 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index ecda7b8..3cb30ef 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,11 @@
+2019-08-20 Bob Duff <duff@adacore.com>
+
+ * 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.
+
2019-08-20 Gary Dismukes <dismukes@adacore.com>
* sem_ch3.adb (OK_For_Limited_Init_In_05): In the case of type
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 05bc6f5..4a77451 100644
--- a/gcc/ada/sem_prag.adb
+++ b/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);