diff mbox series

[Ada] Fix internal error on task allocation and inlining

Message ID 20170907093349.GA75070@adacore.com
State New
Headers show
Series [Ada] Fix internal error on task allocation and inlining | expand

Commit Message

Arnaud Charlet Sept. 7, 2017, 9:33 a.m. UTC
This fixes a small regression introduced by the recent improvement to the
algorithm used by Hide_Public_Entities to compute the final set of external
visible entities of a package.  It now needs to recurse on the Actions list
of freeze nodes to find references to subprograms.

The following procedure must compile quietly with -O -gnatn:

with T;
procedure P is
begin
   T.S;
end;

package T is
   procedure S with Inline;
end;

package body T is
   task type TT;
   task body TT is begin null; end;

   type TTA is access TT;
   X : TTA;

   procedure S is
   begin
      X := new TT;
   end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-09-07  Eric Botcazou  <ebotcazou@adacore.com>

	* sem_ch7.adb (Has_Referencer): Recurse on Actions of freeze
	nodes.
diff mbox series

Patch

Index: sem_ch7.adb
===================================================================
--- sem_ch7.adb	(revision 251785)
+++ sem_ch7.adb	(working copy)
@@ -402,6 +402,18 @@ 
                      end if;
                   end if;
 
+               --  Freeze node
+
+               elsif Nkind (Decl) = N_Freeze_Entity then
+                  declare
+                     Discard : Boolean;
+                     pragma Unreferenced (Discard);
+                  begin
+                     --  Inspect the actions to find references to subprograms
+
+                     Discard := Has_Referencer (Actions (Decl));
+                  end;
+
                --  Exceptions, objects and renamings do not need to be public
                --  if they are not followed by a construct which can reference
                --  and export them. The Is_Public flag is reset on top level
@@ -484,7 +496,7 @@ 
 
          --  Local variables
 
-         Discard : Boolean := True;
+         Discard : Boolean;
          pragma Unreferenced (Discard);
 
       --  Start of processing for Hide_Public_Entities