aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorYannick Moy <moy@adacore.com>2019-07-23 08:13:01 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-23 08:13:01 +0000
commit39c20502ef7398766a8c9520c4210c2df9769d15 (patch)
tree0df1c95911c37142af392c2da93d5aac8422b887 /gcc/ada
parent58b8c5a87b0bac61bb88e802fc742fdc0d3e6699 (diff)
downloadgcc-39c20502ef7398766a8c9520c4210c2df9769d15.zip
gcc-39c20502ef7398766a8c9520c4210c2df9769d15.tar.gz
gcc-39c20502ef7398766a8c9520c4210c2df9769d15.tar.bz2
[Ada] Fix binding of ghost units with finalizer
Linking of an enabled ghost unit which requires a finalizer lead to an error, as the name generated by the binder for calling the finalizer was not the same as the name chosen by the compiler. Now fixed. 2019-07-23 Yannick Moy <moy@adacore.com> gcc/ada/ * exp_ch7.adb (Create_Finalizer): Force finalizer not to be Ghost enabled. * exp_dbug.adb (Get_External_Name): Explain special case of Ghost finalizer. gcc/testsuite/ * gnat.dg/ghost6.adb, gnat.dg/ghost6_pkg.ads: New testcase. From-SVN: r273720
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/exp_ch7.adb7
-rw-r--r--gcc/ada/exp_dbug.adb8
3 files changed, 22 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index db77736..0f7cd2d 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2019-07-23 Yannick Moy <moy@adacore.com>
+
+ * exp_ch7.adb (Create_Finalizer): Force finalizer not to be
+ Ghost enabled.
+ * exp_dbug.adb (Get_External_Name): Explain special case of
+ Ghost finalizer.
+
2019-07-22 Eric Botcazou <ebotcazou@adacore.com>
* repinfo.adb (List_Entities): Also list compiled-generated
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 2ca4109..b00fc92 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -2035,6 +2035,13 @@ package body Exp_Ch7 is
Analyze (Fin_Body, Suppress => All_Checks);
end if;
+
+ -- Never consider that the finalizer procedure is enabled Ghost, even
+ -- when the corresponding unit is Ghost, as this would lead to an
+ -- an external name with a ___ghost_ prefix that the binder cannot
+ -- generate, as it has no knowledge of the Ghost status of units.
+
+ Set_Is_Checked_Ghost_Entity (Fin_Id, False);
end Create_Finalizer;
--------------------------
diff --git a/gcc/ada/exp_dbug.adb b/gcc/ada/exp_dbug.adb
index 388d247..f0df5e2 100644
--- a/gcc/ada/exp_dbug.adb
+++ b/gcc/ada/exp_dbug.adb
@@ -914,6 +914,14 @@ package body Exp_Dbug is
-- names produced for Ghost entities, while "__ghost_" can appear in
-- names of entities inside a child/local package called "Ghost".
+ -- The compiler-generated finalizer for an enabled Ghost unit is treated
+ -- specially, as its name must be known to the binder, which has no
+ -- knowledge of Ghost status. In that case, the finalizer is not marked
+ -- as Ghost so that no prefix is added. Note that the special ___ghost_
+ -- prefix is retained when the Ghost unit is ignored, which still allows
+ -- inspecting the final executable for the presence of an ignored Ghost
+ -- finalizer procedure.
+
if Is_Ghost_Entity (E)
and then not Is_Compilation_Unit (E)
and then (Name_Len < 9