[Ada] Unnesting: do not eliminate subprogram whose address is taken
authorEd Schonberg <schonberg@adacore.com>
Tue, 11 Dec 2018 11:12:21 +0000 (11:12 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 11 Dec 2018 11:12:21 +0000 (11:12 +0000)
2018-12-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* exp_unst.adb (Register_Subprogram): A subprogram whose address
is taken (through attribute Address or Access) is reachable and
cannot be eliminated, even if there is no explicit call to it:
the address may be used in an indirect call or in some
address-related operation.

From-SVN: r267014

gcc/ada/ChangeLog
gcc/ada/exp_unst.adb

index 59d0a3f76aaabbf15f36b11958a8cefabf93b696..b16262327d83a247f0afdcb285810bbec9c088e8 100644 (file)
@@ -1,3 +1,11 @@
+2018-12-11  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_unst.adb (Register_Subprogram): A subprogram whose address
+       is taken (through attribute Address or Access) is reachable and
+       cannot be eliminated, even if there is no explicit call to it:
+       the address may be used in an indirect call or in some
+       address-related operation.
+
 2018-12-11  Ed Schonberg  <schonberg@adacore.com>
 
        * sem_util.adb (Get_Actual_Subtype): Function can return type
index f8c8fd56be1181c2fb0bd3736cca374b325f1aaf..a004b49d9eb4db20c4b8f806a743105ccd968986 100644 (file)
@@ -770,7 +770,8 @@ package body Exp_Unst is
                  ((Ent           => E,
                    Bod           => Bod,
                    Lev           => L,
-                   Reachable     => In_Synchronized_Unit (E),
+                   Reachable     => In_Synchronized_Unit (E)
+                                      or else Address_Taken (E),
                    Uplevel_Ref   => L,
                    Declares_AREC => False,
                    Uents         => No_Elist,