[Ada] Unnesting: handle the semantic of Procedure_To_Call field
authorEd Schonberg <schonberg@adacore.com>
Wed, 30 May 2018 08:58:46 +0000 (08:58 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Wed, 30 May 2018 08:58:46 +0000 (08:58 +0000)
2018-05-30  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* exp_unst.adb (Visit_Node): Handle the semantic Procedure_To_Call
field in relevant nodes: Allocate, Free, and return statements.

From-SVN: r260947

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

index 1e810bbdf61fa47d2d5bea2e64a641967a64fe20..dfe018dbd795a39f44b4c182278552913a1c17f8 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-30  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_unst.adb (Visit_Node): Handle the semantic Procedure_To_Call
+       field in relevant nodes: Allocate, Free, and return statements.
+
 2018-05-30  Ed Schonberg  <schonberg@adacore.com>
 
        * exp_unst.adb (Visit_Node): Do not traverse a Component_Association
index 7935306996e4ddd307a9896596d4a757d9f0aa07..5469f28c79d106ad78807fa0a9d2e9a9b14abd27 100644 (file)
@@ -715,6 +715,26 @@ package body Exp_Unst is
                        ((N, Current_Subprogram, Entity (At_End_Proc (N))));
                   end if;
 
+               --  Similarly, the following constructs include a semantic
+               --  attribute Procedure_To_Call that must be handled like
+               --  other calls.
+
+               when N_Allocator
+                  | N_Free_Statement
+                  | N_Extended_Return_Statement
+                  | N_Simple_Return_Statement
+               =>
+                  declare
+                     Proc : constant Entity_Id := Procedure_To_Call (N);
+                  begin
+                     if Present (Proc)
+                       and then Scope_Within (Proc, Subp)
+                       and then not Is_Imported (Proc)
+                     then
+                        Append_Unique_Call ((N, Current_Subprogram, Proc));
+                     end if;
+                  end;
+
                --  A 'Access reference is a (potential) call.
                --  Other attributes require special handling.