1
- with Uname ; use Uname;
2
1
with Namet ; use Namet;
3
2
with Nlists ; use Nlists;
4
3
with Sem ;
@@ -1000,6 +999,8 @@ package body Tree_Walk is
1000
999
return Symbol
1001
1000
is
1002
1001
U : constant Node_Id := Unit (N);
1002
+ Unit_Name : constant Symbol_Id :=
1003
+ Intern (Unique_Name (Unique_Defining_Entity (U)));
1003
1004
Unit_Symbol : Symbol;
1004
1005
begin
1005
1006
-- Insert all all specifications of all withed units including the
@@ -1008,29 +1009,29 @@ package body Tree_Walk is
1008
1009
1009
1010
case Nkind (U) is
1010
1011
when N_Subprogram_Body =>
1011
- declare
1012
- Unit_Name : constant Symbol_Id :=
1013
- Intern (Unique_Name (Unique_Defining_Entity (U)));
1014
- begin
1015
- -- The specification of the subprogram body has already
1016
- -- been inserted into the symbol table by the call to
1017
- -- Do_Withed_Unit_Specs.
1018
- pragma Assert (Global_Symbol_Table.Contains (Unit_Name));
1019
- Unit_Symbol := Global_Symbol_Table (Unit_Name);
1012
+ -- The specification of the subprogram body has already
1013
+ -- been inserted into the symbol table by the call to
1014
+ -- Do_Withed_Unit_Specs.
1015
+ pragma Assert (Global_Symbol_Table.Contains (Unit_Name));
1016
+ Unit_Symbol := Global_Symbol_Table (Unit_Name);
1020
1017
1021
- -- Now compile the body of the subprogram
1022
- Unit_Symbol.Value := Do_Subprogram_Or_Block (U);
1018
+ -- Now compile the body of the subprogram
1019
+ Unit_Symbol.Value := Do_Subprogram_Or_Block (U);
1023
1020
1024
- -- and update the symbol table entry for this subprogram.
1025
- Global_Symbol_Table.Replace (Unit_Name, Unit_Symbol);
1026
- Unit_Is_Subprogram := True;
1027
- end ;
1021
+ -- and update the symbol table entry for this subprogram.
1022
+ Global_Symbol_Table.Replace (Unit_Name, Unit_Symbol);
1023
+ Unit_Is_Subprogram := True;
1028
1024
1029
1025
when N_Package_Body =>
1030
1026
declare
1031
1027
Dummy : constant Irep := Do_Subprogram_Or_Block (U);
1032
1028
pragma Unreferenced (Dummy);
1033
1029
begin
1030
+ -- The specification of the package body has already
1031
+ -- been inserted into the symbol table by the call to
1032
+ -- Do_Withed_Unit_Specs.
1033
+ pragma Assert (Global_Symbol_Table.Contains (Unit_Name));
1034
+ Unit_Symbol := Global_Symbol_Table (Unit_Name);
1034
1035
Unit_Is_Subprogram := False;
1035
1036
end ;
1036
1037
@@ -3575,7 +3576,35 @@ package body Tree_Walk is
3575
3576
3576
3577
procedure Do_Package_Specification (N : Node_Id) is
3577
3578
Package_Decs : constant Irep := New_Irep (I_Code_Block);
3579
+ Package_Name : Symbol_Id;
3580
+ Package_Symbol : Symbol;
3581
+ Def_Unit_Name : Node_Id;
3582
+ Entity_Node : Node_Id;
3583
+
3578
3584
begin
3585
+ Def_Unit_Name := Defining_Unit_Name (N);
3586
+
3587
+ -- Defining_Unit_Name will return a N_Defining_Identifier
3588
+ -- for non-child package but a N_Package_Specification when it is a
3589
+ -- child package.
3590
+ -- To obtain the Entity N_Defining_Identifier is required.
3591
+ -- The actual parameter for Unique_Name must be an Entity node.
3592
+ if Nkind (Def_Unit_Name) = N_Defining_Identifier then
3593
+ Entity_Node := Def_Unit_Name;
3594
+ else
3595
+ Entity_Node := Defining_Identifier (Def_Unit_Name);
3596
+ end if ;
3597
+
3598
+ Package_Name := Intern (Unique_Name (Entity_Node));
3599
+ Package_Symbol.Name := Package_Name;
3600
+ Package_Symbol.BaseName := Package_Name;
3601
+ Package_Symbol.PrettyName := Package_Name;
3602
+ Package_Symbol.SymType := New_Irep (I_Void_Type);
3603
+ Package_Symbol.Mode := Intern (" C" );
3604
+ Package_Symbol.Value := Make_Nil (Sloc (N));
3605
+
3606
+ Global_Symbol_Table.Insert (Package_Name, Package_Symbol);
3607
+
3579
3608
Set_Source_Location (Package_Decs, Sloc (N));
3580
3609
if Present (Visible_Declarations (N)) then
3581
3610
Process_Declarations (Visible_Declarations (N), Package_Decs);
@@ -4338,12 +4367,9 @@ package body Tree_Walk is
4338
4367
-- -----------------------
4339
4368
4340
4369
procedure Do_Withed_Unit_Spec (N : Node_Id) is
4341
- Unit_Name : constant String := Get_Name_String (Get_Unit_Name (N));
4342
4370
begin
4343
- if Defining_Entity (N) = Stand.Standard_Standard or else
4344
- Unit_Name = " system%s"
4345
- then
4346
- -- At the moment Standard or System are not processed: TODO
4371
+ if Defining_Entity (N) = Stand.Standard_Standard then
4372
+ -- At the moment Standard is not processed: TODO
4347
4373
null ;
4348
4374
else
4349
4375
-- Handle all other withed library unit declarations
@@ -4373,8 +4399,9 @@ package body Tree_Walk is
4373
4399
when N_Package_Body =>
4374
4400
null ;
4375
4401
when others =>
4376
- Put_Line (Standard_Error,
4377
- " This type of library_unit is not yet handled" );
4402
+ Report_Unhandled_Node_Empty
4403
+ (N, " Do_Withed_Unit_Spec" ,
4404
+ " This type of library_unit is not yet handled" );
4378
4405
end case ;
4379
4406
4380
4407
end if ;
@@ -4915,8 +4942,40 @@ package body Tree_Walk is
4915
4942
-- be called from Ada, or a foreign-language variable to be
4916
4943
-- accessed from Ada. This would (probably) require gnat2goto to
4917
4944
-- understand the foreign code, which we do not at the moment.
4918
- Put_Line (Standard_Error,
4919
- " Warning: Multi-language analysis unsupported." );
4945
+ -- However, if the calling convention is specified as "Intrinsic"
4946
+ -- then the subprogram is built into the compiler and gnat2goto
4947
+ -- can safely ignore the pragma.
4948
+ declare
4949
+ -- If the pragma is specified with positional parameter
4950
+ -- association, then the calling convention is the first
4951
+ -- parameter. Check to see if it is Intrinsic.
4952
+ Next_Ass : Node_Id := First (Pragma_Argument_Associations (N));
4953
+ Is_Intrinsic : Boolean := Present (Next_Ass) and then
4954
+ Nkind (Expression (Next_Ass)) = N_Identifier and then
4955
+ Get_Name_String (Chars (Expression (Next_Ass))) = " intrinsic" ;
4956
+ begin
4957
+ -- If the first parameter is not Intrinsic, check named
4958
+ -- parameters for calling convention
4959
+ while not Is_Intrinsic and Present (Next_Ass) loop
4960
+ if Chars (Next_Ass) /= No_Name and then
4961
+ Get_Name_String (Chars (Next_Ass)) = " convention"
4962
+ then
4963
+ -- The named parameter is Convention, check to see if it
4964
+ -- is Intrinsic
4965
+ Is_Intrinsic :=
4966
+ Get_Name_String (Chars (Expression (Next_Ass))) =
4967
+ " intrinsic" ;
4968
+ end if ;
4969
+ -- Get the next parameter association
4970
+ Next_Ass := Next (Next_Ass);
4971
+ end loop ;
4972
+
4973
+ if not Is_Intrinsic then
4974
+ Put_Line (Standard_Error,
4975
+ " Warning: Multi-language analysis unsupported." );
4976
+ end if ;
4977
+ end ;
4978
+
4920
4979
when Name_Elaborate =>
4921
4980
-- Specifies that the body of the named library unit is elaborated
4922
4981
-- before the current library_item. We will support packages.
0 commit comments