===================================================================
@@ -937,7 +937,8 @@
---------------------------------
procedure Analyze_Package_Declaration (N : Node_Id) is
- Id : constant Node_Id := Defining_Entity (N);
+ Id : constant Node_Id := Defining_Entity (N);
+ Par : constant Node_Id := Parent_Spec (N);
Body_Required : Boolean;
-- True when this package declaration requires a corresponding body
@@ -972,10 +973,13 @@
Set_SPARK_Aux_Pragma_Inherited (Id);
end if;
- -- A package declared within a Ghost refion is automatically Ghost
- -- (SPARK RM 6.9(2)).
+ -- A package declared within a Ghost refion is automatically Ghost. A
+ -- child package is Ghost when its parent is Ghost (SPARK RM 6.9(2)).
- if Ghost_Mode > None then
+ if Ghost_Mode > None
+ or else (Present (Par)
+ and then Is_Ghost_Entity (Defining_Entity (Unit (Par))))
+ then
Set_Is_Ghost_Entity (Id);
end if;
===================================================================
@@ -747,16 +747,16 @@
----------------------
procedure Write_With_Lines is
- With_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 1));
- Num_Withs : Int := 0;
- Unum : Unit_Number_Type;
- Cunit : Node_Id;
- Uname : Unit_Name_Type;
- Fname : File_Name_Type;
Pname : constant Unit_Name_Type :=
Get_Parent_Spec_Name (Unit_Name (Main_Unit));
Body_Fname : File_Name_Type;
Body_Index : Nat;
+ Cunit : Node_Id;
+ Fname : File_Name_Type;
+ Num_Withs : Int := 0;
+ Unum : Unit_Number_Type;
+ Uname : Unit_Name_Type;
+ With_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 1));
procedure Write_With_File_Names
(Nam : in out File_Name_Type;
@@ -814,11 +814,19 @@
Sort (With_Table (1 .. Num_Withs));
for J in 1 .. Num_Withs loop
- Unum := With_Table (J);
- Cunit := Units.Table (Unum).Cunit;
- Uname := Units.Table (Unum).Unit_Name;
- Fname := Units.Table (Unum).Unit_File_Name;
+ Unum := With_Table (J);
+ -- Do not generate a with line for an ignored Ghost unit because
+ -- the unit does not have an ALI file.
+
+ if Is_Ignored_Ghost_Entity (Cunit_Entity (Unum)) then
+ goto Next_With_Line;
+ end if;
+
+ Cunit := Units.Table (Unum).Cunit;
+ Uname := Units.Table (Unum).Unit_Name;
+ Fname := Units.Table (Unum).Unit_File_Name;
+
if Implicit_With (Unum) = Yes then
Write_Info_Initiate ('Z');
@@ -914,6 +922,9 @@
end if;
Write_Info_EOL;
+
+ <<Next_With_Line>>
+ null;
end loop;
-- Finally generate the special lines for cases of Restriction_Set
@@ -932,7 +943,7 @@
for U in 0 .. Last_Unit loop
if Unit_Name (U) = Unam then
- goto Continue;
+ goto Next_Restriction_Set;
end if;
end loop;
@@ -943,7 +954,7 @@
Write_Info_Name (Unam);
Write_Info_EOL;
- <<Continue>>
+ <<Next_Restriction_Set>>
null;
end loop;
end;
@@ -996,8 +1007,8 @@
end if;
end if;
- -- Otherwise acquire compilation arguments and prepare to write
- -- out a new ali file.
+ -- Otherwise acquire compilation arguments and prepare to write out a
+ -- new ali file.
Create_Output_Library_Info;
===================================================================
@@ -15063,6 +15063,12 @@
and then No (Corresponding_Spec (Context))
then
Id := Defining_Entity (Context);
+
+ -- Pragma Ghost applies to a subprogram declaration that acts
+ -- as a compilation unit.
+
+ elsif Nkind (Context) = N_Subprogram_Declaration then
+ Id := Defining_Entity (Context);
end if;
end if;