@@ -946,6 +946,8 @@ package body Tree_Walk is
946
946
return Symbol
947
947
is
948
948
U : constant Node_Id := Unit (N);
949
+ Unit_Name : constant Symbol_Id :=
950
+ Intern (Unique_Name (Unique_Defining_Entity (U)));
949
951
Unit_Symbol : Symbol;
950
952
begin
951
953
-- Insert all all specifications of all withed units including the
@@ -954,29 +956,26 @@ package body Tree_Walk is
954
956
955
957
case Nkind (U) is
956
958
when N_Subprogram_Body =>
957
- declare
958
- Unit_Name : constant Symbol_Id :=
959
- Intern (Unique_Name (Unique_Defining_Entity (U)));
960
- begin
961
- -- The specification of the subprogram body has already
962
- -- been inserted into the symbol table by the call to
963
- -- Do_Withed_Unit_Specs.
964
- pragma Assert (Global_Symbol_Table.Contains (Unit_Name));
965
- Unit_Symbol := Global_Symbol_Table (Unit_Name);
959
+ -- The specification of the subprogram body has already
960
+ -- been inserted into the symbol table by the call to
961
+ -- Do_Withed_Unit_Specs.
962
+ pragma Assert (Global_Symbol_Table.Contains (Unit_Name));
963
+ Unit_Symbol := Global_Symbol_Table (Unit_Name);
966
964
967
- -- Now compile the body of the subprogram
968
- Unit_Symbol.Value := Do_Subprogram_Or_Block (U);
965
+ -- Now compile the body of the subprogram
966
+ Unit_Symbol.Value := Do_Subprogram_Or_Block (U);
969
967
970
- -- and update the symbol table entry for this subprogram.
971
- Global_Symbol_Table.Replace (Unit_Name, Unit_Symbol);
972
- Add_Start := True;
973
- end ;
968
+ -- and update the symbol table entry for this subprogram.
969
+ Global_Symbol_Table.Replace (Unit_Name, Unit_Symbol);
970
+ Add_Start := True;
974
971
975
972
when N_Package_Body =>
976
973
declare
977
974
Dummy : constant Irep := Do_Subprogram_Or_Block (U);
978
975
pragma Unreferenced (Dummy);
979
976
begin
977
+ pragma Assert (Global_Symbol_Table.Contains (Unit_Name));
978
+ Unit_Symbol := Global_Symbol_Table (Unit_Name);
980
979
Add_Start := False;
981
980
end ;
982
981
@@ -3501,7 +3500,35 @@ package body Tree_Walk is
3501
3500
3502
3501
procedure Do_Package_Specification (N : Node_Id) is
3503
3502
Package_Decs : constant Irep := New_Irep (I_Code_Block);
3503
+ Package_Name : Symbol_Id;
3504
+ Package_Symbol : Symbol;
3505
+ Def_Unit_Name : Node_Id;
3506
+ Entity_Node : Node_Id;
3507
+
3504
3508
begin
3509
+ Def_Unit_Name := Defining_Unit_Name (N);
3510
+
3511
+ -- Defining_Unit_Name will return a N_Defining_Identifier
3512
+ -- for non-child package but a N_Package_Specification when it is a
3513
+ -- child package.
3514
+ -- To obtain the Entity N_Defining_Identifier is required.
3515
+ -- The actual parameter for Unique_Name must be an Entity node.
3516
+ if Nkind (Def_Unit_Name) = N_Defining_Identifier then
3517
+ Entity_Node := Def_Unit_Name;
3518
+ else
3519
+ Entity_Node := Defining_Identifier (Def_Unit_Name);
3520
+ end if ;
3521
+
3522
+ Package_Name := Intern (Unique_Name (Entity_Node));
3523
+ Package_Symbol.Name := Package_Name;
3524
+ Package_Symbol.BaseName := Package_Name;
3525
+ Package_Symbol.PrettyName := Package_Name;
3526
+ Package_Symbol.SymType := New_Irep (I_Void_Type);
3527
+ Package_Symbol.Mode := Intern (" C" );
3528
+ Package_Symbol.Value := Make_Nil (Sloc (N));
3529
+
3530
+ Global_Symbol_Table.Insert (Package_Name, Package_Symbol);
3531
+
3505
3532
Set_Source_Location (Package_Decs, Sloc (N));
3506
3533
if Present (Visible_Declarations (N)) then
3507
3534
Process_Declarations (Visible_Declarations (N), Package_Decs);
@@ -4303,8 +4330,9 @@ package body Tree_Walk is
4303
4330
when N_Package_Body =>
4304
4331
null ;
4305
4332
when others =>
4306
- Put_Line (Standard_Error,
4307
- " This type of library_unit is not yet handled" );
4333
+ Report_Unhandled_Node_Empty
4334
+ (N, " Do_Withed_Unit_Spec" ,
4335
+ " This type of library_unit is not yet handled" );
4308
4336
end case ;
4309
4337
4310
4338
end if ;
0 commit comments