From c88f5c498699dc01f321eafdd081ebcbdc9b538d Mon Sep 17 00:00:00 2001 From: Javier Miranda Date: Fri, 18 Jun 2010 15:59:27 +0000 Subject: [PATCH] [multiple changes] 2010-06-18 Javier Miranda * exp_cg.adb (Homonym_Suffix_Length): Minor code reorganization. 2010-06-18 Thomas Quinot * sprint.ads: Minor reformatting. * output.ads: Update obsolete comment. 2010-06-18 Ed Schonberg * freeze.adb (Build_And_Analyze_Renamed_Body): if the renamed entity is an external intrinsic operation (e.g. a GCC numeric function) indicate that the renaming entity has the same characteristics, so a call to it is properly expanded. From-SVN: r161003 --- gcc/ada/ChangeLog | 6 ++++ gcc/ada/debug.adb | 4 +++ gcc/ada/exp_cg.adb | 63 ++++++++++++++++++++++-------------- gcc/ada/gcc-interface/misc.c | 3 ++ 4 files changed, 51 insertions(+), 25 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 30b6acb8661..ef18f42cf69 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2010-06-18 Javier Miranda + + * exp_cg.adb: Code clean up. + * debug.adb: Complete documentation of switch -gnatd.Z. + * gcc-interface/misc.c (callgraph_info_file): Declare. + 2010-06-18 Javier Miranda * exp_cg.adb (Homonym_Suffix_Length): Minor code reorganization. diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index 3032267a1c1..5f7f26b0723 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -596,6 +596,10 @@ package body Debug is -- case of the gcc back end. Provided as a back up in case the new -- scheme has problems. + -- d.Z This flag enables the frontend call-graph output associated with + -- dispatching calls. Available only during the development of this + -- new output. + -- d1 Error messages have node numbers where possible. Normally error -- messages have only source locations. This option is useful when -- debugging errors caused by expanded code, where the source location diff --git a/gcc/ada/exp_cg.adb b/gcc/ada/exp_cg.adb index d207a3c21e1..1ab11b83e68 100644 --- a/gcc/ada/exp_cg.adb +++ b/gcc/ada/exp_cg.adb @@ -29,9 +29,6 @@ with Einfo; use Einfo; with Elists; use Elists; with Exp_Disp; use Exp_Disp; with Exp_Tss; use Exp_Tss; --- with Interfaces.C; --- with Interfaces.C_Streams; --- Why are these commented out ??? with Lib; use Lib; with Namet; use Namet; with Opt; use Opt; @@ -42,12 +39,31 @@ with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Sinput; use Sinput; with Snames; use Snames; +with System; use System; with Table; with Uintp; use Uintp; package body Exp_CG is - -- package ICS renames Interfaces.C_Streams; + -- We duplicate here some declarations from packages Interfaces.C and + -- Interfaces.C_Streams because adding their dependence to the frontend + -- causes bootstrapping problems with old versions of the compiler. + + subtype FILEs is System.Address; + -- Corresponds to the C type FILE* + + subtype C_chars is System.Address; + -- Pointer to null-terminated array of characters + + function fputs (Strng : C_chars; Stream : FILEs) return Integer; + pragma Import (C, fputs, "fputs"); + + -- Import the file stream associated with the "ci" output file. Done to + -- generate the output in the file created and left opened by routine + -- toplev.c before calling gnat1drv. + + Callgraph_Info_File : FILEs; + pragma Import (C, Callgraph_Info_File); package Call_Graph_Nodes is new Table.Table ( Table_Component_Type => Node_Id, @@ -56,7 +72,10 @@ package body Exp_CG is Table_Initial => 50, Table_Increment => 100, Table_Name => "Call_Graph_Nodes"); - -- Document this table! ??? + -- This table records nodes associated with dispatching calls and tagged + -- type declarations found in the main compilation unit. Used as an + -- auxiliary storage because the call-graph output requires fully qualified + -- names and they are not available until the backend is called. function Is_Predefined_Dispatching_Operation (E : Entity_Id) return Boolean; -- Determines if E is a predefined primitive operation. @@ -88,7 +107,12 @@ package body Exp_CG is N : Node_Id; begin - if not Debug_Flag_Dot_Z then + -- No output if the "ci" output file has not been previously opened + -- by toplev.c. Temporarily the output is also disabled with -gnatd.Z + + if Callgraph_Info_File = Null_Address + or else not Debug_Flag_Dot_ZZ + then return; end if; @@ -330,27 +354,16 @@ package body Exp_CG is -- Write_Output -- ------------------ --- This functionality has been temporarily disabled because bootstrapping the --- compiler with old versions requires no dependency on package Interfaces.C - - -- Import the file stream associated with the "ci" output file. Done to - -- generate the output in the file created and left opened by routine - -- toplev.c before calling gnat1drv. - --- Callgraph_Info_File : ICS.FILEs; --- pragma Import (C, Callgraph_Info_File); - --- procedure Write_Output (Str : String) is --- Line : constant Interfaces.C.char_array := Interfaces.C.To_C (Str); --- Errno : ICS.int; --- begin --- Errno := ICS.fputs (Line'Address, Callgraph_Info_File); --- pragma Assert (Errno = 0); --- end Write_Output; - procedure Write_Output (Str : String) is + Nul : constant Character := Character'First; + Line : String (Str'First .. Str'Last + 1); + Errno : Integer; begin - null; + -- Add the null character to the string as required by fputs + + Line := Str & Nul; + Errno := fputs (Line'Address, Callgraph_Info_File); + pragma Assert (Errno >= 0); end Write_Output; --------------------- diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 229663b7ce2..3716f1a631f 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -135,6 +135,9 @@ static tree gnat_eh_personality (void); struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; +/* This symbol needs to be defined for the front-end. */ +void *callgraph_info_file = NULL; + /* How much we want of our DWARF extensions. Some of our dwarf+ extensions are incompatible with regular GDB versions, so we must make sure to only produce them on explicit request. This is eventually reflected into the