[Ada] Fix issues with ignored ghost code and unnesting

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.
This commit is contained in:
Richard Kenner 2021-11-16 09:39:57 -05:00 committed by Pierre-Marie de Rodat
parent dbdb6b93a2
commit be6bb3fc57
2 changed files with 16 additions and 10 deletions

View 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;

View 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;