]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix issues with ignored ghost code and unnesting
authorRichard Kenner <kenner@adacore.com>
Tue, 16 Nov 2021 14:39:57 +0000 (09:39 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 1 Dec 2021 10:24:41 +0000 (10:24 +0000)
gcc/ada/

* frontend.adb (Frontend): Do unnesting after ignored ghost code
has been removed.
* inline.adb (Analyze_Inlined_Bodies): Don't put ignored ghost
entities on inlined subprogram list.

gcc/ada/frontend.adb
gcc/ada/inline.adb

index a65b3e1b4109cab7f6580802ee59273829729011..b78fc9cf30d68002b69a106794fcf999b3e6c394 100644 (file)
@@ -473,12 +473,6 @@ begin
                Check_Elaboration_Scenarios;
             end if;
 
-            --  At this stage we can unnest subprogram bodies if required
-
-            if Total_Errors_Detected = 0 then
-               Exp_Unst.Unnest_Subprograms (Cunit (Main_Unit));
-            end if;
-
             --  List library units if requested
 
             if List_Units then
@@ -494,12 +488,19 @@ begin
             Sem_Warn.Output_Unused_Warnings_Off_Warnings;
 
             --  Remove any ignored Ghost code as it must not appear in the
-            --  executable. This action must be performed last because it
+            --  executable. This action must be performed very late because it
             --  heavily alters the tree.
 
             if Operating_Mode = Generate_Code or else GNATprove_Mode then
                Remove_Ignored_Ghost_Code;
             end if;
+
+            --  At this stage we can unnest subprogram bodies if required
+
+            if Total_Errors_Detected = 0 then
+               Exp_Unst.Unnest_Subprograms (Cunit (Main_Unit));
+            end if;
+
          end if;
       end if;
    end;
index 08c454d366e62ebf84cb4ae7fcb8c1a49bbd48da..11a5523f4b7eec6c8509c9fbd147a2250e6719d4 100644 (file)
@@ -1087,9 +1087,14 @@ package body Inline is
          --  subprograms for the unit.
 
          for Index in Inlined.First .. Inlined.Last loop
-            if Is_Called (Inlined.Table (Index).Name) then
-               Add_Inlined_Subprogram (Inlined.Table (Index).Name);
-            end if;
+            declare
+               E : constant Subprogram_Kind_Id := Inlined.Table (Index).Name;
+
+            begin
+               if Is_Called (E) and then not Is_Ignored_Ghost_Entity (E) then
+                  Add_Inlined_Subprogram (E);
+               end if;
+            end;
          end loop;
 
          Pop_Scope;