diff options
author | Bob Duff <duff@adacore.com> | 2009-04-17 14:11:04 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-17 14:11:04 +0200 |
commit | b1b543d2c07b470207d4b347d6b2a9af6d488da7 (patch) | |
tree | 6e957cad5a9b6a8086189a2bb0175f2b72b4a7bd /gcc/ada/sem_ch6.adb | |
parent | e31f58141167c7eecd9bd9cdcf1a6a9cdd528f32 (diff) | |
download | gcc-b1b543d2c07b470207d4b347d6b2a9af6d488da7.tar.gz |
output.ads (Indent,Outdent): New procedures for indenting the output.
2009-04-17 Bob Duff <duff@adacore.com>
* output.ads (Indent,Outdent): New procedures for indenting the output.
(Write_Char): Correct comment -- LF _is_ allowed.
* output.adb (Indent,Outdent): New procedures for indenting the output.
Keep track of the indentation level, and make sure it doesn't get too
high.
(Flush_Buffer): Insert spaces at the beginning of each line, if
indentation level is nonzero.
(Save_Output_Buffer,Restore_Output_Buffer): Save and restore the current
indentation level.
(Set_Standard_Error,Set_Standard_Output): Remove superfluous
"Next_Col := 1;". Flush_Buffer does that.
* sem_ch6.adb, sem_ch7.adb (Debug_Flag_C): Reorganize the output
controlled by the -gnatdc switch. It now occurs on entry/exit to the
relevant analysis routines, and calls Indent/Outdent to make the
indentation reflect the nesting level. Add "helper" routines, since
otherwise lots of "return;" statements would skip the debugging output.
From-SVN: r146253
Diffstat (limited to 'gcc/ada/sem_ch6.adb')
-rw-r--r-- | gcc/ada/sem_ch6.adb | 81 |
1 files changed, 60 insertions, 21 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 080b3e06013..a9dd4af54e1 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -107,6 +107,9 @@ package body Sem_Ch6 is -- specification, in a context where the formals are visible and hide -- outer homographs. + procedure Analyze_Subprogram_Body_Helper (N : Node_Id); + -- Does all the real work of Analyze_Subprogram_Body + procedure Analyze_Generic_Subprogram_Body (N : Node_Id; Gen_Id : Entity_Id); -- Analyze a generic subprogram body. N is the body to be analyzed, and -- Gen_Id is the defining entity Id for the corresponding spec. @@ -1342,12 +1345,48 @@ package body Sem_Ch6 is -- Analyze_Subprogram_Body -- ----------------------------- + procedure Analyze_Subprogram_Body (N : Node_Id) is + Loc : constant Source_Ptr := Sloc (N); + Body_Spec : constant Node_Id := Specification (N); + Body_Id : constant Entity_Id := Defining_Entity (Body_Spec); + + begin + if Debug_Flag_C then + Write_Str ("==> subprogram body "); + Write_Name (Chars (Body_Id)); + Write_Str (" from "); + Write_Location (Loc); + Write_Eol; + Indent; + end if; + + Trace_Scope (N, Body_Id, " Analyze subprogram: "); + + -- The real work is split out into the helper, so it can do "return;" + -- without skipping the debug output: + + Analyze_Subprogram_Body_Helper (N); + + if Debug_Flag_C then + Outdent; + Write_Str ("<== subprogram body "); + Write_Name (Chars (Body_Id)); + Write_Str (" from "); + Write_Location (Loc); + Write_Eol; + end if; + end Analyze_Subprogram_Body; + + ------------------------------------ + -- Analyze_Subprogram_Body_Helper -- + ------------------------------------ + -- This procedure is called for regular subprogram bodies, generic bodies, -- and for subprogram stubs of both kinds. In the case of stubs, only the -- specification matters, and is used to create a proper declaration for -- the subprogram, or to perform conformance checks. - procedure Analyze_Subprogram_Body (N : Node_Id) is + procedure Analyze_Subprogram_Body_Helper (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Body_Deleted : constant Boolean := False; Body_Spec : constant Node_Id := Specification (N); @@ -1785,19 +1824,9 @@ package body Sem_Ch6 is end if; end Verify_Overriding_Indicator; - -- Start of processing for Analyze_Subprogram_Body + -- Start of processing for Analyze_Subprogram_Body_Helper begin - if Debug_Flag_C then - Write_Str ("==== Compiling subprogram body "); - Write_Name (Chars (Body_Id)); - Write_Str (" from "); - Write_Location (Loc); - Write_Eol; - end if; - - Trace_Scope (N, Body_Id, " Analyze subprogram: "); - -- Generic subprograms are handled separately. They always have a -- generic specification. Determine whether current scope has a -- previous declaration. @@ -2558,7 +2587,7 @@ package body Sem_Ch6 is Check_References (Body_Id); end if; end; - end Analyze_Subprogram_Body; + end Analyze_Subprogram_Body_Helper; ------------------------------------ -- Analyze_Subprogram_Declaration -- @@ -2572,6 +2601,15 @@ package body Sem_Ch6 is -- Start of processing for Analyze_Subprogram_Declaration begin + if Debug_Flag_C then + Write_Str ("==> subprogram spec "); + Write_Name (Chars (Designator)); + Write_Str (" from "); + Write_Location (Sloc (N)); + Write_Eol; + Indent; + end if; + Generate_Definition (Designator); -- Check for RCI unit subprogram declarations for illegal inlined @@ -2585,14 +2623,6 @@ package body Sem_Ch6 is Defining_Entity (N), " Analyze subprogram spec: "); - if Debug_Flag_C then - Write_Str ("==== Compiling subprogram spec "); - Write_Name (Chars (Designator)); - Write_Str (" from "); - Write_Location (Sloc (N)); - Write_Eol; - end if; - New_Overloaded_Entity (Designator); Check_Delayed_Subprogram (Designator); @@ -2712,6 +2742,15 @@ package body Sem_Ch6 is ("protected operation cannot be a null procedure", N); end if; end if; + + if Debug_Flag_C then + Outdent; + Write_Str ("<== subprogram spec "); + Write_Name (Chars (Designator)); + Write_Str (" from "); + Write_Location (Sloc (N)); + Write_Eol; + end if; end Analyze_Subprogram_Declaration; -------------------------------------- |