OSDN Git Service

./:
[pf3gnuchains/gcc-fork.git] / gcc / ada / sprint.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               S P R I N T                                --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2007, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 with Atree;    use Atree;
28 with Casing;   use Casing;
29 with Csets;    use Csets;
30 with Debug;    use Debug;
31 with Einfo;    use Einfo;
32 with Fname;    use Fname;
33 with Lib;      use Lib;
34 with Namet;    use Namet;
35 with Nlists;   use Nlists;
36 with Opt;      use Opt;
37 with Output;   use Output;
38 with Rtsfind;  use Rtsfind;
39 with Sinfo;    use Sinfo;
40 with Sinput;   use Sinput;
41 with Sinput.D; use Sinput.D;
42 with Snames;   use Snames;
43 with Stand;    use Stand;
44 with Stringt;  use Stringt;
45 with Uintp;    use Uintp;
46 with Uname;    use Uname;
47 with Urealp;   use Urealp;
48
49 package body Sprint is
50    Current_Source_File : Source_File_Index;
51    --  Index of source file whose generated code is being dumped
52
53    Dump_Node : Node_Id := Empty;
54    --  This is set to the current node, used for printing line numbers. In
55    --  Debug_Generated_Code mode, Dump_Node is set to the current node
56    --  requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
57    --  value. The call clears it back to Empty.
58
59    Debug_Sloc : Source_Ptr;
60    --  Sloc of first byte of line currently being written if we are
61    --  generating a source debug file.
62
63    Dump_Original_Only : Boolean;
64    --  Set True if the -gnatdo (dump original tree) flag is set
65
66    Dump_Generated_Only : Boolean;
67    --  Set True if the -gnatG (dump generated tree) debug flag is set
68    --  or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
69
70    Dump_Freeze_Null : Boolean;
71    --  Set True if freeze nodes and non-source null statements output
72
73    Freeze_Indent : Int := 0;
74    --  Keep track of freeze indent level (controls output of blank lines before
75    --  procedures within expression freeze actions). Relevant only if we are
76    --  not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
77    --  output these blank lines in any case.
78
79    Indent : Int := 0;
80    --  Number of columns for current line output indentation
81
82    Indent_Annull_Flag : Boolean := False;
83    --  Set True if subsequent Write_Indent call to be ignored, gets reset
84    --  by this call, so it is only active to suppress a single indent call.
85
86    Last_Line_Printed : Physical_Line_Number;
87    --  This keeps track of the physical line number of the last source line
88    --  that has been output. The value is only valid in Dump_Source_Text mode.
89
90    Line_Limit : constant := 72;
91    --  Limit value for chopping long lines
92
93    -------------------------------
94    -- Operator Precedence Table --
95    -------------------------------
96
97    --  This table is used to decide whether a subexpression needs to be
98    --  parenthesized. The rule is that if an operand of an operator (which
99    --  for this purpose includes AND THEN and OR ELSE) is itself an operator
100    --  with a lower precedence than the operator (or equal precedence if
101    --  appearing as the right operand), then parentheses are required.
102
103    Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
104                (N_Op_And          => 1,
105                 N_Op_Or           => 1,
106                 N_Op_Xor          => 1,
107                 N_And_Then        => 1,
108                 N_Or_Else         => 1,
109
110                 N_In              => 2,
111                 N_Not_In          => 2,
112                 N_Op_Eq           => 2,
113                 N_Op_Ge           => 2,
114                 N_Op_Gt           => 2,
115                 N_Op_Le           => 2,
116                 N_Op_Lt           => 2,
117                 N_Op_Ne           => 2,
118
119                 N_Op_Add          => 3,
120                 N_Op_Concat       => 3,
121                 N_Op_Subtract     => 3,
122                 N_Op_Plus         => 3,
123                 N_Op_Minus        => 3,
124
125                 N_Op_Divide       => 4,
126                 N_Op_Mod          => 4,
127                 N_Op_Rem          => 4,
128                 N_Op_Multiply     => 4,
129
130                 N_Op_Expon        => 5,
131                 N_Op_Abs          => 5,
132                 N_Op_Not          => 5,
133
134                 others            => 6);
135
136    procedure Sprint_Left_Opnd (N : Node_Id);
137    --  Print left operand of operator, parenthesizing if necessary
138
139    procedure Sprint_Right_Opnd (N : Node_Id);
140    --  Print right operand of operator, parenthesizing if necessary
141
142    -----------------------
143    -- Local Subprograms --
144    -----------------------
145
146    procedure Col_Check (N : Nat);
147    --  Check that at least N characters remain on current line, and if not,
148    --  then start an extra line with two characters extra indentation for
149    --  continuing text on the next line.
150
151    procedure Extra_Blank_Line;
152    --  In some situations we write extra blank lines to separate the generated
153    --  code to make it more readable. However, these extra blank lines are not
154    --  generated in Dump_Source_Text mode, since there the source text lines
155    --  output with preceding blank lines are quite sufficient as separators.
156    --  This procedure writes a blank line if Dump_Source_Text is False.
157
158    procedure Indent_Annull;
159    --  Causes following call to Write_Indent to be ignored. This is used when
160    --  a higher level node wants to stop a lower level node from starting a
161    --  new line, when it would otherwise be inclined to do so (e.g. the case
162    --  of an accept statement called from an accept alternative with a guard)
163
164    procedure Indent_Begin;
165    --  Increase indentation level
166
167    procedure Indent_End;
168    --  Decrease indentation level
169
170    procedure Note_Implicit_Run_Time_Call (N : Node_Id);
171    --  N is the Name field of a function call or procedure statement call.
172    --  The effect of the call is to output a $ if the call is identified as
173    --  an implicit call to a run time routine.
174
175    procedure Print_Debug_Line (S : String);
176    --  Used to print output lines in Debug_Generated_Code mode (this is used
177    --  as the argument for a call to Set_Special_Output in package Output).
178
179    procedure Process_TFAI_RR_Flags (Nod : Node_Id);
180    --  Given a divide, multiplication or division node, check the flags
181    --  Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
182    --  appropriate special syntax characters (# and @).
183
184    procedure Set_Debug_Sloc;
185    --  If Dump_Node is non-empty, this routine sets the appropriate value
186    --  in its Sloc field, from the current location in the debug source file
187    --  that is currently being written.
188
189    procedure Sprint_And_List (List : List_Id);
190    --  Print the given list with items separated by vertical "and"
191
192    procedure Sprint_Bar_List (List : List_Id);
193    --  Print the given list with items separated by vertical bars
194
195    procedure Sprint_End_Label
196      (Node    : Node_Id;
197       Default : Node_Id);
198    --  Print the end label for a Handled_Sequence_Of_Statements in a body.
199    --  If there is not end label, use the defining identifier of the enclosing
200    --  construct. If the end label is present, treat it as a reference to the
201    --  defining entity of the construct: this guarantees that it carries the
202    --  proper sloc information for debugging purposes.
203
204    procedure Sprint_Node_Actual (Node : Node_Id);
205    --  This routine prints its node argument. It is a lower level routine than
206    --  Sprint_Node, in that it does not bother about rewritten trees.
207
208    procedure Sprint_Node_Sloc (Node : Node_Id);
209    --  Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
210    --  sets the Sloc of the current debug node to be a copy of the Sloc
211    --  of the sprinted node Node. Note that this is done after printing
212    --  Node, so that the Sloc is the proper updated value for the debug file.
213
214    procedure Update_Itype (Node : Node_Id);
215    --  Update the Sloc of an itype that is not attached to the tree, when
216    --  debugging expanded code. This routine is called from nodes whose
217    --  type can be an Itype, such as defining_identifiers that may be of
218    --  an anonymous access type, or ranges in slices.
219
220    procedure Write_Char_Sloc (C : Character);
221    --  Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
222    --  called to ensure that the current node has a proper Sloc set.
223
224    procedure Write_Condition_And_Reason (Node : Node_Id);
225    --  Write Condition and Reason codes of Raise_xxx_Error node
226
227    procedure Write_Corresponding_Source (S : String);
228    --  If S is a string with a single keyword (possibly followed by a space),
229    --  and if the next non-comment non-blank source line matches this keyword,
230    --  then output all source lines up to this matching line.
231
232    procedure Write_Discr_Specs (N : Node_Id);
233    --  Ouput discriminant specification for node, which is any of the type
234    --  declarations that can have discriminants.
235
236    procedure Write_Ekind (E : Entity_Id);
237    --  Write the String corresponding to the Ekind without "E_"
238
239    procedure Write_Id (N : Node_Id);
240    --  N is a node with a Chars field. This procedure writes the name that
241    --  will be used in the generated code associated with the name. For a
242    --  node with no associated entity, this is simply the Chars field. For
243    --  the case where there is an entity associated with the node, we print
244    --  the name associated with the entity (since it may have been encoded).
245    --  One other special case is that an entity has an active external name
246    --  (i.e. an external name present with no address clause), then this
247    --  external name is output. This procedure also deals with outputting
248    --  declarations of referenced itypes, if not output earlier.
249
250    function Write_Identifiers (Node : Node_Id) return Boolean;
251    --  Handle node where the grammar has a list of defining identifiers, but
252    --  the tree has a separate declaration for each identifier. Handles the
253    --  printing of the defining identifier, and returns True if the type and
254    --  initialization information is to be printed, False if it is to be
255    --  skipped (the latter case happens when printing defining identifiers
256    --  other than the first in the original tree output case).
257
258    procedure Write_Implicit_Def (E : Entity_Id);
259    pragma Warnings (Off, Write_Implicit_Def);
260    --  Write the definition of the implicit type E according to its Ekind
261    --  For now a debugging procedure, but might be used in the future.
262
263    procedure Write_Indent;
264    --  Start a new line and write indentation spacing
265
266    function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
267    --  Like Write_Identifiers except that each new printed declaration
268    --  is at the start of a new line.
269
270    function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
271    --  Like Write_Indent_Identifiers except that in Debug_Generated_Code
272    --  mode, the Sloc of the current debug node is set to point ot the
273    --  first output identifier.
274
275    procedure Write_Indent_Str (S : String);
276    --  Start a new line and write indent spacing followed by given string
277
278    procedure Write_Indent_Str_Sloc (S : String);
279    --  Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
280    --  the Sloc of the current node is set to the first non-blank character
281    --  in the string S.
282
283    procedure Write_Itype (Typ : Entity_Id);
284    --  If Typ is an Itype that has not been written yet, write it. If Typ is
285    --  any other kind of entity or tree node, the call is ignored.
286
287    procedure Write_Name_With_Col_Check (N : Name_Id);
288    --  Write name (using Write_Name) with initial column check, and possible
289    --  initial Write_Indent (to get new line) if current line is too full.
290
291    procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
292    --  Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
293    --  mode, sets Sloc of current debug node to first character of name.
294
295    procedure Write_Operator (N : Node_Id; S : String);
296    --  Like Write_Str_Sloc, used for operators, encloses the string in
297    --  characters {} if the Do_Overflow flag is set on the node N.
298
299    procedure Write_Param_Specs (N : Node_Id);
300    --  Output parameter specifications for node (which is either a function
301    --  or procedure specification with a Parameter_Specifications field)
302
303    procedure Write_Rewrite_Str (S : String);
304    --  Writes out a string (typically containing <<< or >>>}) for a node
305    --  created by rewriting the tree. Suppressed if we are outputting the
306    --  generated code only, since in this case we don't specially mark nodes
307    --  created by rewriting).
308
309    procedure Write_Source_Line (L : Physical_Line_Number);
310    --  If writing of interspersed source lines is enabled, then write the given
311    --  line from the source file, preceded by Eol, then an extra blank line if
312    --  the line has at least one blank, is not a comment and is not line one,
313    --  then "--" and the line number followed by period followed by text of the
314    --  source line (without terminating Eol). If interspersed source line
315    --  output not enabled, then the call has no effect.
316
317    procedure Write_Source_Lines (L : Physical_Line_Number);
318    --  If writing of interspersed source lines is enabled, then writes source
319    --  lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
320    --  interspersed source line output not enabled, then call has no effect.
321
322    procedure Write_Str_Sloc (S : String);
323    --  Like Write_Str, but sets debug Sloc of current debug node to first
324    --  non-blank character if a current debug node is active.
325
326    procedure Write_Str_With_Col_Check (S : String);
327    --  Write string (using Write_Str) with initial column check, and possible
328    --  initial Write_Indent (to get new line) if current line is too full.
329
330    procedure Write_Str_With_Col_Check_Sloc (S : String);
331    --  Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
332    --  node to first non-blank character if a current debug node is active.
333
334    procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format);
335    --  Write Uint (using UI_Write) with initial column check, and possible
336    --  initial Write_Indent (to get new line) if current line is too full.
337    --  The format parameter determines the output format (see UI_Write).
338
339    procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
340    --  Write Uint (using UI_Write) with initial column check, and possible
341    --  initial Write_Indent (to get new line) if current line is too full.
342    --  The format parameter determines the output format (see UI_Write).
343    --  In addition, in Debug_Generated_Code mode, sets the current node
344    --  Sloc to the first character of the output value.
345
346    procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
347    --  Write Ureal (using same output format as UR_Write) with column checks
348    --  and a possible initial Write_Indent (to get new line) if current line
349    --  is too full. In addition, in Debug_Generated_Code mode, sets the
350    --  current node Sloc to the first character of the output value.
351
352    ---------------
353    -- Col_Check --
354    ---------------
355
356    procedure Col_Check (N : Nat) is
357    begin
358       if N + Column > Line_Limit then
359          Write_Indent_Str ("  ");
360       end if;
361    end Col_Check;
362
363    ----------------------
364    -- Extra_Blank_Line --
365    ----------------------
366
367    procedure Extra_Blank_Line is
368    begin
369       if not Dump_Source_Text then
370          Write_Indent;
371       end if;
372    end Extra_Blank_Line;
373
374    -------------------
375    -- Indent_Annull --
376    -------------------
377
378    procedure Indent_Annull is
379    begin
380       Indent_Annull_Flag := True;
381    end Indent_Annull;
382
383    ------------------
384    -- Indent_Begin --
385    ------------------
386
387    procedure Indent_Begin is
388    begin
389       Indent := Indent + 3;
390    end Indent_Begin;
391
392    ----------------
393    -- Indent_End --
394    ----------------
395
396    procedure Indent_End is
397    begin
398       Indent := Indent - 3;
399    end Indent_End;
400
401    ---------------------------------
402    -- Note_Implicit_Run_Time_Call --
403    ---------------------------------
404
405    procedure Note_Implicit_Run_Time_Call (N : Node_Id) is
406    begin
407       if not Comes_From_Source (N)
408         and then Is_Entity_Name (N)
409       then
410          declare
411             Ent : constant Entity_Id := Entity (N);
412          begin
413             if not In_Extended_Main_Source_Unit (Ent)
414               and then
415                 Is_Predefined_File_Name
416                   (Unit_File_Name (Get_Source_Unit (Ent)))
417             then
418                Col_Check (Length_Of_Name (Chars (Ent)));
419                Write_Char ('$');
420             end if;
421          end;
422       end if;
423    end Note_Implicit_Run_Time_Call;
424
425    --------
426    -- pg --
427    --------
428
429    procedure pg (Arg : Union_Id) is
430    begin
431       Dump_Generated_Only := True;
432       Dump_Original_Only := False;
433       Current_Source_File := No_Source_File;
434
435       if Arg in List_Range then
436          Sprint_Node_List (List_Id (Arg));
437
438       elsif Arg in Node_Range then
439          Sprint_Node (Node_Id (Arg));
440
441       else
442          null;
443       end if;
444
445       Write_Eol;
446    end pg;
447
448    --------
449    -- po --
450    --------
451
452    procedure po (Arg : Union_Id) is
453    begin
454       Dump_Generated_Only := False;
455       Dump_Original_Only := True;
456       Current_Source_File := No_Source_File;
457
458       if Arg in List_Range then
459          Sprint_Node_List (List_Id (Arg));
460
461       elsif Arg in Node_Range then
462          Sprint_Node (Node_Id (Arg));
463
464       else
465          null;
466       end if;
467
468       Write_Eol;
469    end po;
470
471    ----------------------
472    -- Print_Debug_Line --
473    ----------------------
474
475    procedure Print_Debug_Line (S : String) is
476    begin
477       Write_Debug_Line (S, Debug_Sloc);
478    end Print_Debug_Line;
479
480    ---------------------------
481    -- Process_TFAI_RR_Flags --
482    ---------------------------
483
484    procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
485    begin
486       if Treat_Fixed_As_Integer (Nod) then
487          Write_Char ('#');
488       end if;
489
490       if Rounded_Result (Nod) then
491          Write_Char ('@');
492       end if;
493    end Process_TFAI_RR_Flags;
494
495    --------
496    -- ps --
497    --------
498
499    procedure ps (Arg : Union_Id) is
500    begin
501       Dump_Generated_Only := False;
502       Dump_Original_Only := False;
503       Current_Source_File := No_Source_File;
504
505       if Arg in List_Range then
506          Sprint_Node_List (List_Id (Arg));
507
508       elsif Arg in Node_Range then
509          Sprint_Node (Node_Id (Arg));
510
511       else
512          null;
513       end if;
514
515       Write_Eol;
516    end ps;
517
518    --------------------
519    -- Set_Debug_Sloc --
520    --------------------
521
522    procedure Set_Debug_Sloc is
523    begin
524       if Debug_Generated_Code and then Present (Dump_Node) then
525          Set_Sloc (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1));
526          Dump_Node := Empty;
527       end if;
528    end Set_Debug_Sloc;
529
530    -----------------
531    -- Source_Dump --
532    -----------------
533
534    procedure Source_Dump is
535
536       procedure Underline;
537       --  Put underline under string we just printed
538
539       ---------------
540       -- Underline --
541       ---------------
542
543       procedure Underline is
544          Col : constant Int := Column;
545
546       begin
547          Write_Eol;
548
549          while Col > Column loop
550             Write_Char ('-');
551          end loop;
552
553          Write_Eol;
554       end Underline;
555
556    --  Start of processing for Tree_Dump
557
558    begin
559       Dump_Generated_Only := Debug_Flag_G or
560                              Print_Generated_Code or
561                              Debug_Generated_Code;
562       Dump_Original_Only  := Debug_Flag_O;
563       Dump_Freeze_Null    := Debug_Flag_S or Debug_Flag_G;
564
565       --  Note that we turn off the tree dump flags immediately, before
566       --  starting the dump. This avoids generating two copies of the dump
567       --  if an abort occurs after printing the dump, and more importantly,
568       --  avoids an infinite loop if an abort occurs during the dump.
569
570       if Debug_Flag_Z then
571          Current_Source_File := No_Source_File;
572          Debug_Flag_Z := False;
573          Write_Eol;
574          Write_Eol;
575          Write_Str ("Source recreated from tree of Standard (spec)");
576          Underline;
577          Sprint_Node (Standard_Package_Node);
578          Write_Eol;
579          Write_Eol;
580       end if;
581
582       if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
583          Debug_Flag_G := False;
584          Debug_Flag_O := False;
585          Debug_Flag_S := False;
586
587          --  Dump requested units
588
589          for U in Main_Unit .. Last_Unit loop
590             Current_Source_File := Source_Index (U);
591
592             --  Dump all units if -gnatdf set, otherwise we dump only
593             --  the source files that are in the extended main source.
594
595             if Debug_Flag_F
596               or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
597             then
598                --  If we are generating debug files, setup to write them
599
600                if Debug_Generated_Code then
601                   Set_Special_Output (Print_Debug_Line'Access);
602                   Create_Debug_Source (Source_Index (U), Debug_Sloc);
603                   Write_Source_Line (1);
604                   Last_Line_Printed := 1;
605                   Sprint_Node (Cunit (U));
606                   Write_Source_Lines (Last_Source_Line (Current_Source_File));
607                   Write_Eol;
608                   Close_Debug_Source;
609                   Set_Special_Output (null);
610
611                --  Normal output to standard output file
612
613                else
614                   Write_Str ("Source recreated from tree for ");
615                   Write_Unit_Name (Unit_Name (U));
616                   Underline;
617                   Write_Source_Line (1);
618                   Last_Line_Printed := 1;
619                   Sprint_Node (Cunit (U));
620                   Write_Source_Lines (Last_Source_Line (Current_Source_File));
621                   Write_Eol;
622                   Write_Eol;
623                end if;
624             end if;
625          end loop;
626       end if;
627    end Source_Dump;
628
629    ---------------------
630    -- Sprint_And_List --
631    ---------------------
632
633    procedure Sprint_And_List (List : List_Id) is
634       Node : Node_Id;
635    begin
636       if Is_Non_Empty_List (List) then
637          Node := First (List);
638          loop
639             Sprint_Node (Node);
640             Next (Node);
641             exit when Node = Empty;
642             Write_Str (" and ");
643          end loop;
644       end if;
645    end Sprint_And_List;
646
647    ---------------------
648    -- Sprint_Bar_List --
649    ---------------------
650
651    procedure Sprint_Bar_List (List : List_Id) is
652       Node : Node_Id;
653    begin
654       if Is_Non_Empty_List (List) then
655          Node := First (List);
656          loop
657             Sprint_Node (Node);
658             Next (Node);
659             exit when Node = Empty;
660             Write_Str (" | ");
661          end loop;
662       end if;
663    end Sprint_Bar_List;
664
665    ----------------------
666    -- Sprint_End_Label --
667    ----------------------
668
669    procedure Sprint_End_Label
670      (Node    : Node_Id;
671       Default : Node_Id)
672    is
673    begin
674       if Present (Node)
675         and then Present (End_Label (Node))
676         and then Is_Entity_Name (End_Label (Node))
677       then
678          Set_Entity (End_Label (Node), Default);
679
680          --  For a function whose name is an operator, use the qualified name
681          --  created for the defining entity.
682
683          if Nkind (End_Label (Node)) = N_Operator_Symbol then
684             Set_Chars (End_Label (Node), Chars (Default));
685          end if;
686
687          Sprint_Node (End_Label (Node));
688       else
689          Sprint_Node (Default);
690       end if;
691    end Sprint_End_Label;
692
693    -----------------------
694    -- Sprint_Comma_List --
695    -----------------------
696
697    procedure Sprint_Comma_List (List : List_Id) is
698       Node : Node_Id;
699
700    begin
701       if Is_Non_Empty_List (List) then
702          Node := First (List);
703          loop
704             Sprint_Node (Node);
705             Next (Node);
706             exit when Node = Empty;
707
708             if not Is_Rewrite_Insertion (Node)
709               or else not Dump_Original_Only
710             then
711                Write_Str (", ");
712             end if;
713          end loop;
714       end if;
715    end Sprint_Comma_List;
716
717    --------------------------
718    -- Sprint_Indented_List --
719    --------------------------
720
721    procedure Sprint_Indented_List (List : List_Id) is
722    begin
723       Indent_Begin;
724       Sprint_Node_List (List);
725       Indent_End;
726    end Sprint_Indented_List;
727
728    ---------------------
729    -- Sprint_Left_Opnd --
730    ---------------------
731
732    procedure Sprint_Left_Opnd (N : Node_Id) is
733       Opnd : constant Node_Id := Left_Opnd (N);
734
735    begin
736       if Paren_Count (Opnd) /= 0
737         or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
738       then
739          Sprint_Node (Opnd);
740
741       else
742          Write_Char ('(');
743          Sprint_Node (Opnd);
744          Write_Char (')');
745       end if;
746    end Sprint_Left_Opnd;
747
748    -----------------
749    -- Sprint_Node --
750    -----------------
751
752    procedure Sprint_Node (Node : Node_Id) is
753    begin
754       if Is_Rewrite_Insertion (Node) then
755          if not Dump_Original_Only then
756
757             --  For special cases of nodes that always output <<< >>>
758             --  do not duplicate the output at this point.
759
760             if Nkind (Node) = N_Freeze_Entity
761               or else Nkind (Node) = N_Implicit_Label_Declaration
762             then
763                Sprint_Node_Actual (Node);
764
765             --  Normal case where <<< >>> may be required
766
767             else
768                Write_Rewrite_Str ("<<<");
769                Sprint_Node_Actual (Node);
770                Write_Rewrite_Str (">>>");
771             end if;
772          end if;
773
774       elsif Is_Rewrite_Substitution (Node) then
775
776          --  Case of dump generated only
777
778          if Dump_Generated_Only then
779             Sprint_Node_Actual (Node);
780
781          --  Case of dump original only
782
783          elsif Dump_Original_Only then
784             Sprint_Node_Actual (Original_Node (Node));
785
786          --  Case of both being dumped
787
788          else
789             Sprint_Node_Actual (Original_Node (Node));
790             Write_Rewrite_Str ("<<<");
791             Sprint_Node_Actual (Node);
792             Write_Rewrite_Str (">>>");
793          end if;
794
795       else
796          Sprint_Node_Actual (Node);
797       end if;
798    end Sprint_Node;
799
800    ------------------------
801    -- Sprint_Node_Actual --
802    ------------------------
803
804    procedure Sprint_Node_Actual (Node : Node_Id) is
805       Save_Dump_Node : constant Node_Id := Dump_Node;
806
807    begin
808       if Node = Empty then
809          return;
810       end if;
811
812       for J in 1 .. Paren_Count (Node) loop
813          Write_Str_With_Col_Check ("(");
814       end loop;
815
816       --  Setup current dump node
817
818       Dump_Node := Node;
819
820       if Nkind (Node) in N_Subexpr
821         and then Do_Range_Check (Node)
822       then
823          Write_Str_With_Col_Check ("{");
824       end if;
825
826       --  Select print circuit based on node kind
827
828       case Nkind (Node) is
829
830          when N_Abort_Statement =>
831             Write_Indent_Str_Sloc ("abort ");
832             Sprint_Comma_List (Names (Node));
833             Write_Char (';');
834
835          when N_Abortable_Part =>
836             Set_Debug_Sloc;
837             Write_Str_Sloc ("abort ");
838             Sprint_Indented_List (Statements (Node));
839
840          when N_Abstract_Subprogram_Declaration =>
841             Write_Indent;
842             Sprint_Node (Specification (Node));
843             Write_Str_With_Col_Check (" is ");
844             Write_Str_Sloc ("abstract;");
845
846          when N_Accept_Alternative =>
847             Sprint_Node_List (Pragmas_Before (Node));
848
849             if Present (Condition (Node)) then
850                Write_Indent_Str ("when ");
851                Sprint_Node (Condition (Node));
852                Write_Str (" => ");
853                Indent_Annull;
854             end if;
855
856             Sprint_Node_Sloc (Accept_Statement (Node));
857             Sprint_Node_List (Statements (Node));
858
859          when N_Accept_Statement =>
860             Write_Indent_Str_Sloc ("accept ");
861             Write_Id (Entry_Direct_Name (Node));
862
863             if Present (Entry_Index (Node)) then
864                Write_Str_With_Col_Check (" (");
865                Sprint_Node (Entry_Index (Node));
866                Write_Char (')');
867             end if;
868
869             Write_Param_Specs (Node);
870
871             if Present (Handled_Statement_Sequence (Node)) then
872                Write_Str_With_Col_Check (" do");
873                Sprint_Node (Handled_Statement_Sequence (Node));
874                Write_Indent_Str ("end ");
875                Write_Id (Entry_Direct_Name (Node));
876             end if;
877
878             Write_Char (';');
879
880          when N_Access_Definition =>
881
882             --  Ada 2005 (AI-254)
883
884             if Present (Access_To_Subprogram_Definition (Node)) then
885                Sprint_Node (Access_To_Subprogram_Definition (Node));
886             else
887                --  Ada 2005 (AI-231)
888
889                if Null_Exclusion_Present (Node) then
890                   Write_Str ("not null ");
891                end if;
892
893                Write_Str_With_Col_Check_Sloc ("access ");
894
895                if All_Present (Node) then
896                   Write_Str ("all ");
897                elsif Constant_Present (Node) then
898                   Write_Str ("constant ");
899                end if;
900
901                Sprint_Node (Subtype_Mark (Node));
902             end if;
903
904          when N_Access_Function_Definition =>
905
906             --  Ada 2005 (AI-231)
907
908             if Null_Exclusion_Present (Node) then
909                Write_Str ("not null ");
910             end if;
911
912             Write_Str_With_Col_Check_Sloc ("access ");
913
914             if Protected_Present (Node) then
915                Write_Str_With_Col_Check ("protected ");
916             end if;
917
918             Write_Str_With_Col_Check ("function");
919             Write_Param_Specs (Node);
920             Write_Str_With_Col_Check (" return ");
921             Sprint_Node (Result_Definition (Node));
922
923          when N_Access_Procedure_Definition =>
924
925             --  Ada 2005 (AI-231)
926
927             if Null_Exclusion_Present (Node) then
928                Write_Str ("not null ");
929             end if;
930
931             Write_Str_With_Col_Check_Sloc ("access ");
932
933             if Protected_Present (Node) then
934                Write_Str_With_Col_Check ("protected ");
935             end if;
936
937             Write_Str_With_Col_Check ("procedure");
938             Write_Param_Specs (Node);
939
940          when N_Access_To_Object_Definition =>
941             Write_Str_With_Col_Check_Sloc ("access ");
942
943             if All_Present (Node) then
944                Write_Str_With_Col_Check ("all ");
945             elsif Constant_Present (Node) then
946                Write_Str_With_Col_Check ("constant ");
947             end if;
948
949             --  Ada 2005 (AI-231)
950
951             if Null_Exclusion_Present (Node) then
952                Write_Str ("not null ");
953             end if;
954
955             Sprint_Node (Subtype_Indication (Node));
956
957          when N_Aggregate =>
958             if Null_Record_Present (Node) then
959                Write_Str_With_Col_Check_Sloc ("(null record)");
960
961             else
962                Write_Str_With_Col_Check_Sloc ("(");
963
964                if Present (Expressions (Node)) then
965                   Sprint_Comma_List (Expressions (Node));
966
967                   if Present (Component_Associations (Node)) then
968                      Write_Str (", ");
969                   end if;
970                end if;
971
972                if Present (Component_Associations (Node)) then
973                   Indent_Begin;
974
975                   declare
976                      Nd : Node_Id;
977
978                   begin
979                      Nd := First (Component_Associations (Node));
980
981                      loop
982                         Write_Indent;
983                         Sprint_Node (Nd);
984                         Next (Nd);
985                         exit when No (Nd);
986
987                         if not Is_Rewrite_Insertion (Nd)
988                           or else not Dump_Original_Only
989                         then
990                            Write_Str (", ");
991                         end if;
992                      end loop;
993                   end;
994
995                   Indent_End;
996                end if;
997
998                Write_Char (')');
999             end if;
1000
1001          when N_Allocator =>
1002             Write_Str_With_Col_Check_Sloc ("new ");
1003
1004             --  Ada 2005 (AI-231)
1005
1006             if Null_Exclusion_Present (Node) then
1007                Write_Str ("not null ");
1008             end if;
1009
1010             Sprint_Node (Expression (Node));
1011
1012             if Present (Storage_Pool (Node)) then
1013                Write_Str_With_Col_Check ("[storage_pool = ");
1014                Sprint_Node (Storage_Pool (Node));
1015                Write_Char (']');
1016             end if;
1017
1018          when N_And_Then =>
1019             Sprint_Left_Opnd (Node);
1020             Write_Str_Sloc (" and then ");
1021             Sprint_Right_Opnd (Node);
1022
1023          when N_At_Clause =>
1024             Write_Indent_Str_Sloc ("for ");
1025             Write_Id (Identifier (Node));
1026             Write_Str_With_Col_Check (" use at ");
1027             Sprint_Node (Expression (Node));
1028             Write_Char (';');
1029
1030          when N_Assignment_Statement =>
1031             Write_Indent;
1032             Sprint_Node (Name (Node));
1033             Write_Str_Sloc (" := ");
1034             Sprint_Node (Expression (Node));
1035             Write_Char (';');
1036
1037          when N_Asynchronous_Select =>
1038             Write_Indent_Str_Sloc ("select");
1039             Indent_Begin;
1040             Sprint_Node (Triggering_Alternative (Node));
1041             Indent_End;
1042
1043             --  Note: let the printing of Abortable_Part handle outputting
1044             --  the ABORT keyword, so that the Slco can be set correctly.
1045
1046             Write_Indent_Str ("then ");
1047             Sprint_Node (Abortable_Part (Node));
1048             Write_Indent_Str ("end select;");
1049
1050          when N_Attribute_Definition_Clause =>
1051             Write_Indent_Str_Sloc ("for ");
1052             Sprint_Node (Name (Node));
1053             Write_Char (''');
1054             Write_Name_With_Col_Check (Chars (Node));
1055             Write_Str_With_Col_Check (" use ");
1056             Sprint_Node (Expression (Node));
1057             Write_Char (';');
1058
1059          when N_Attribute_Reference =>
1060             if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1061                Write_Indent;
1062             end if;
1063
1064             Sprint_Node (Prefix (Node));
1065             Write_Char_Sloc (''');
1066             Write_Name_With_Col_Check (Attribute_Name (Node));
1067             Sprint_Paren_Comma_List (Expressions (Node));
1068
1069             if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1070                Write_Char (';');
1071             end if;
1072
1073          when N_Block_Statement =>
1074             Write_Indent;
1075
1076             if Present (Identifier (Node))
1077               and then (not Has_Created_Identifier (Node)
1078                           or else not Dump_Original_Only)
1079             then
1080                Write_Rewrite_Str ("<<<");
1081                Write_Id (Identifier (Node));
1082                Write_Str (" : ");
1083                Write_Rewrite_Str (">>>");
1084             end if;
1085
1086             if Present (Declarations (Node)) then
1087                Write_Str_With_Col_Check_Sloc ("declare");
1088                Sprint_Indented_List (Declarations (Node));
1089                Write_Indent;
1090             end if;
1091
1092             Write_Str_With_Col_Check_Sloc ("begin");
1093             Sprint_Node (Handled_Statement_Sequence (Node));
1094             Write_Indent_Str ("end");
1095
1096             if Present (Identifier (Node))
1097               and then (not Has_Created_Identifier (Node)
1098                           or else not Dump_Original_Only)
1099             then
1100                Write_Rewrite_Str ("<<<");
1101                Write_Char (' ');
1102                Write_Id (Identifier (Node));
1103                Write_Rewrite_Str (">>>");
1104             end if;
1105
1106             Write_Char (';');
1107
1108          when N_Case_Statement =>
1109             Write_Indent_Str_Sloc ("case ");
1110             Sprint_Node (Expression (Node));
1111             Write_Str (" is");
1112             Sprint_Indented_List (Alternatives (Node));
1113             Write_Indent_Str ("end case;");
1114
1115          when N_Case_Statement_Alternative =>
1116             Write_Indent_Str_Sloc ("when ");
1117             Sprint_Bar_List (Discrete_Choices (Node));
1118             Write_Str (" => ");
1119             Sprint_Indented_List (Statements (Node));
1120
1121          when N_Character_Literal =>
1122             if Column > 70 then
1123                Write_Indent_Str ("  ");
1124             end if;
1125
1126             Write_Char_Sloc (''');
1127             Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
1128             Write_Char (''');
1129
1130          when N_Code_Statement =>
1131             Write_Indent;
1132             Set_Debug_Sloc;
1133             Sprint_Node (Expression (Node));
1134             Write_Char (';');
1135
1136          when N_Compilation_Unit =>
1137             Sprint_Node_List (Context_Items (Node));
1138             Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
1139
1140             if Private_Present (Node) then
1141                Write_Indent_Str ("private ");
1142                Indent_Annull;
1143             end if;
1144
1145             Sprint_Node_Sloc (Unit (Node));
1146
1147             if Present (Actions (Aux_Decls_Node (Node)))
1148                  or else
1149                Present (Pragmas_After (Aux_Decls_Node (Node)))
1150             then
1151                Write_Indent;
1152             end if;
1153
1154             Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
1155             Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
1156
1157          when N_Compilation_Unit_Aux =>
1158             null; -- nothing to do, never used, see above
1159
1160          when N_Component_Association =>
1161             Set_Debug_Sloc;
1162             Sprint_Bar_List (Choices (Node));
1163             Write_Str (" => ");
1164
1165             --  Ada 2005 (AI-287): Print the box if present
1166
1167             if Box_Present (Node) then
1168                Write_Str_With_Col_Check ("<>");
1169             else
1170                Sprint_Node (Expression (Node));
1171             end if;
1172
1173          when N_Component_Clause =>
1174             Write_Indent;
1175             Sprint_Node (Component_Name (Node));
1176             Write_Str_Sloc (" at ");
1177             Sprint_Node (Position (Node));
1178             Write_Char (' ');
1179             Write_Str_With_Col_Check ("range ");
1180             Sprint_Node (First_Bit (Node));
1181             Write_Str (" .. ");
1182             Sprint_Node (Last_Bit (Node));
1183             Write_Char (';');
1184
1185          when N_Component_Definition =>
1186             Set_Debug_Sloc;
1187
1188             --  Ada 2005 (AI-230): Access definition components
1189
1190             if Present (Access_Definition (Node)) then
1191                Sprint_Node (Access_Definition (Node));
1192
1193             elsif Present (Subtype_Indication (Node)) then
1194                if Aliased_Present (Node) then
1195                   Write_Str_With_Col_Check ("aliased ");
1196                end if;
1197
1198                --  Ada 2005 (AI-231)
1199
1200                if Null_Exclusion_Present (Node) then
1201                   Write_Str (" not null ");
1202                end if;
1203
1204                Sprint_Node (Subtype_Indication (Node));
1205
1206             else
1207                Write_Str (" ??? ");
1208             end if;
1209
1210          when N_Component_Declaration =>
1211             if Write_Indent_Identifiers_Sloc (Node) then
1212                Write_Str (" : ");
1213                Sprint_Node (Component_Definition (Node));
1214
1215                if Present (Expression (Node)) then
1216                   Write_Str (" := ");
1217                   Sprint_Node (Expression (Node));
1218                end if;
1219
1220                Write_Char (';');
1221             end if;
1222
1223          when N_Component_List =>
1224             if Null_Present (Node) then
1225                Indent_Begin;
1226                Write_Indent_Str_Sloc ("null");
1227                Write_Char (';');
1228                Indent_End;
1229
1230             else
1231                Set_Debug_Sloc;
1232                Sprint_Indented_List (Component_Items (Node));
1233                Sprint_Node (Variant_Part (Node));
1234             end if;
1235
1236          when N_Conditional_Entry_Call =>
1237             Write_Indent_Str_Sloc ("select");
1238             Indent_Begin;
1239             Sprint_Node (Entry_Call_Alternative (Node));
1240             Indent_End;
1241             Write_Indent_Str ("else");
1242             Sprint_Indented_List (Else_Statements (Node));
1243             Write_Indent_Str ("end select;");
1244
1245          when N_Conditional_Expression =>
1246             declare
1247                Condition : constant Node_Id := First (Expressions (Node));
1248                Then_Expr : constant Node_Id := Next (Condition);
1249                Else_Expr : constant Node_Id := Next (Then_Expr);
1250             begin
1251                Write_Str_With_Col_Check_Sloc ("(if ");
1252                Sprint_Node (Condition);
1253                Write_Str_With_Col_Check (" then ");
1254                Sprint_Node (Then_Expr);
1255                Write_Str_With_Col_Check (" else ");
1256                Sprint_Node (Else_Expr);
1257                Write_Char (')');
1258             end;
1259
1260          when N_Constrained_Array_Definition =>
1261             Write_Str_With_Col_Check_Sloc ("array ");
1262             Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1263             Write_Str (" of ");
1264
1265             Sprint_Node (Component_Definition (Node));
1266
1267          when N_Decimal_Fixed_Point_Definition =>
1268             Write_Str_With_Col_Check_Sloc (" delta ");
1269             Sprint_Node (Delta_Expression (Node));
1270             Write_Str_With_Col_Check ("digits ");
1271             Sprint_Node (Digits_Expression (Node));
1272             Sprint_Opt_Node (Real_Range_Specification (Node));
1273
1274          when N_Defining_Character_Literal =>
1275             Write_Name_With_Col_Check_Sloc (Chars (Node));
1276
1277          when N_Defining_Identifier =>
1278             Set_Debug_Sloc;
1279             Write_Id (Node);
1280
1281          when N_Defining_Operator_Symbol =>
1282             Write_Name_With_Col_Check_Sloc (Chars (Node));
1283
1284          when N_Defining_Program_Unit_Name =>
1285             Set_Debug_Sloc;
1286             Sprint_Node (Name (Node));
1287             Write_Char ('.');
1288             Write_Id (Defining_Identifier (Node));
1289
1290          when N_Delay_Alternative =>
1291             Sprint_Node_List (Pragmas_Before (Node));
1292
1293             if Present (Condition (Node)) then
1294                Write_Indent;
1295                Write_Str_With_Col_Check ("when ");
1296                Sprint_Node (Condition (Node));
1297                Write_Str (" => ");
1298                Indent_Annull;
1299             end if;
1300
1301             Sprint_Node_Sloc (Delay_Statement (Node));
1302             Sprint_Node_List (Statements (Node));
1303
1304          when N_Delay_Relative_Statement =>
1305             Write_Indent_Str_Sloc ("delay ");
1306             Sprint_Node (Expression (Node));
1307             Write_Char (';');
1308
1309          when N_Delay_Until_Statement =>
1310             Write_Indent_Str_Sloc ("delay until ");
1311             Sprint_Node (Expression (Node));
1312             Write_Char (';');
1313
1314          when N_Delta_Constraint =>
1315             Write_Str_With_Col_Check_Sloc ("delta ");
1316             Sprint_Node (Delta_Expression (Node));
1317             Sprint_Opt_Node (Range_Constraint (Node));
1318
1319          when N_Derived_Type_Definition =>
1320             if Abstract_Present (Node) then
1321                Write_Str_With_Col_Check ("abstract ");
1322             end if;
1323
1324             Write_Str_With_Col_Check_Sloc ("new ");
1325
1326             --  Ada 2005 (AI-231)
1327
1328             if Null_Exclusion_Present (Node) then
1329                Write_Str_With_Col_Check ("not null ");
1330             end if;
1331
1332             Sprint_Node (Subtype_Indication (Node));
1333
1334             if Present (Interface_List (Node)) then
1335                Sprint_And_List (Interface_List (Node));
1336                Write_Str_With_Col_Check (" with ");
1337             end if;
1338
1339             if Present (Record_Extension_Part (Node)) then
1340                if No (Interface_List (Node)) then
1341                   Write_Str_With_Col_Check (" with ");
1342                end if;
1343
1344                Sprint_Node (Record_Extension_Part (Node));
1345             end if;
1346
1347          when N_Designator =>
1348             Sprint_Node (Name (Node));
1349             Write_Char_Sloc ('.');
1350             Write_Id (Identifier (Node));
1351
1352          when N_Digits_Constraint =>
1353             Write_Str_With_Col_Check_Sloc ("digits ");
1354             Sprint_Node (Digits_Expression (Node));
1355             Sprint_Opt_Node (Range_Constraint (Node));
1356
1357          when N_Discriminant_Association =>
1358             Set_Debug_Sloc;
1359
1360             if Present (Selector_Names (Node)) then
1361                Sprint_Bar_List (Selector_Names (Node));
1362                Write_Str (" => ");
1363             end if;
1364
1365             Set_Debug_Sloc;
1366             Sprint_Node (Expression (Node));
1367
1368          when N_Discriminant_Specification =>
1369             Set_Debug_Sloc;
1370
1371             if Write_Identifiers (Node) then
1372                Write_Str (" : ");
1373
1374                if Null_Exclusion_Present (Node) then
1375                   Write_Str ("not null ");
1376                end if;
1377
1378                Sprint_Node (Discriminant_Type (Node));
1379
1380                if Present (Expression (Node)) then
1381                   Write_Str (" := ");
1382                   Sprint_Node (Expression (Node));
1383                end if;
1384             else
1385                Write_Str (", ");
1386             end if;
1387
1388          when N_Elsif_Part =>
1389             Write_Indent_Str_Sloc ("elsif ");
1390             Sprint_Node (Condition (Node));
1391             Write_Str_With_Col_Check (" then");
1392             Sprint_Indented_List (Then_Statements (Node));
1393
1394          when N_Empty =>
1395             null;
1396
1397          when N_Entry_Body =>
1398             Write_Indent_Str_Sloc ("entry ");
1399             Write_Id (Defining_Identifier (Node));
1400             Sprint_Node (Entry_Body_Formal_Part (Node));
1401             Write_Str_With_Col_Check (" is");
1402             Sprint_Indented_List (Declarations (Node));
1403             Write_Indent_Str ("begin");
1404             Sprint_Node (Handled_Statement_Sequence (Node));
1405             Write_Indent_Str ("end ");
1406             Write_Id (Defining_Identifier (Node));
1407             Write_Char (';');
1408
1409          when N_Entry_Body_Formal_Part =>
1410             if Present (Entry_Index_Specification (Node)) then
1411                Write_Str_With_Col_Check_Sloc (" (");
1412                Sprint_Node (Entry_Index_Specification (Node));
1413                Write_Char (')');
1414             end if;
1415
1416             Write_Param_Specs (Node);
1417             Write_Str_With_Col_Check_Sloc (" when ");
1418             Sprint_Node (Condition (Node));
1419
1420          when N_Entry_Call_Alternative =>
1421             Sprint_Node_List (Pragmas_Before (Node));
1422             Sprint_Node_Sloc (Entry_Call_Statement (Node));
1423             Sprint_Node_List (Statements (Node));
1424
1425          when N_Entry_Call_Statement =>
1426             Write_Indent;
1427             Sprint_Node_Sloc (Name (Node));
1428             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1429             Write_Char (';');
1430
1431          when N_Entry_Declaration =>
1432             Write_Indent_Str_Sloc ("entry ");
1433             Write_Id (Defining_Identifier (Node));
1434
1435             if Present (Discrete_Subtype_Definition (Node)) then
1436                Write_Str_With_Col_Check (" (");
1437                Sprint_Node (Discrete_Subtype_Definition (Node));
1438                Write_Char (')');
1439             end if;
1440
1441             Write_Param_Specs (Node);
1442             Write_Char (';');
1443
1444          when N_Entry_Index_Specification =>
1445             Write_Str_With_Col_Check_Sloc ("for ");
1446             Write_Id (Defining_Identifier (Node));
1447             Write_Str_With_Col_Check (" in ");
1448             Sprint_Node (Discrete_Subtype_Definition (Node));
1449
1450          when N_Enumeration_Representation_Clause =>
1451             Write_Indent_Str_Sloc ("for ");
1452             Write_Id (Identifier (Node));
1453             Write_Str_With_Col_Check (" use ");
1454             Sprint_Node (Array_Aggregate (Node));
1455             Write_Char (';');
1456
1457          when N_Enumeration_Type_Definition =>
1458             Set_Debug_Sloc;
1459
1460             --  Skip attempt to print Literals field if it's not there and
1461             --  we are in package Standard (case of Character, which is
1462             --  handled specially (without an explicit literals list).
1463
1464             if Sloc (Node) > Standard_Location
1465               or else Present (Literals (Node))
1466             then
1467                Sprint_Paren_Comma_List (Literals (Node));
1468             end if;
1469
1470          when N_Error =>
1471             Write_Str_With_Col_Check_Sloc ("<error>");
1472
1473          when N_Exception_Declaration =>
1474             if Write_Indent_Identifiers (Node) then
1475                Write_Str_With_Col_Check (" : ");
1476
1477                if Is_Statically_Allocated (Defining_Identifier (Node)) then
1478                   Write_Str_With_Col_Check ("static ");
1479                end if;
1480
1481                Write_Str_Sloc ("exception");
1482
1483                if Present (Expression (Node)) then
1484                   Write_Str (" := ");
1485                   Sprint_Node (Expression (Node));
1486                end if;
1487
1488                Write_Char (';');
1489             end if;
1490
1491          when N_Exception_Handler =>
1492             Write_Indent_Str_Sloc ("when ");
1493
1494             if Present (Choice_Parameter (Node)) then
1495                Sprint_Node (Choice_Parameter (Node));
1496                Write_Str (" : ");
1497             end if;
1498
1499             Sprint_Bar_List (Exception_Choices (Node));
1500             Write_Str (" => ");
1501             Sprint_Indented_List (Statements (Node));
1502
1503          when N_Exception_Renaming_Declaration =>
1504             Write_Indent;
1505             Set_Debug_Sloc;
1506             Sprint_Node (Defining_Identifier (Node));
1507             Write_Str_With_Col_Check (" : exception renames ");
1508             Sprint_Node (Name (Node));
1509             Write_Char (';');
1510
1511          when N_Exit_Statement =>
1512             Write_Indent_Str_Sloc ("exit");
1513             Sprint_Opt_Node (Name (Node));
1514
1515             if Present (Condition (Node)) then
1516                Write_Str_With_Col_Check (" when ");
1517                Sprint_Node (Condition (Node));
1518             end if;
1519
1520             Write_Char (';');
1521
1522          when N_Expanded_Name =>
1523             Sprint_Node (Prefix (Node));
1524             Write_Char_Sloc ('.');
1525             Sprint_Node (Selector_Name (Node));
1526
1527          when N_Explicit_Dereference =>
1528             Sprint_Node (Prefix (Node));
1529             Write_Char_Sloc ('.');
1530             Write_Str_Sloc ("all");
1531
1532          when N_Extended_Return_Statement =>
1533             Write_Indent_Str_Sloc ("return ");
1534             Sprint_Node_List (Return_Object_Declarations (Node));
1535
1536             if Present (Handled_Statement_Sequence (Node)) then
1537                Write_Str_With_Col_Check (" do");
1538                Sprint_Node (Handled_Statement_Sequence (Node));
1539                Write_Indent_Str ("end return;");
1540             else
1541                Write_Indent_Str (";");
1542             end if;
1543
1544          when N_Extension_Aggregate =>
1545             Write_Str_With_Col_Check_Sloc ("(");
1546             Sprint_Node (Ancestor_Part (Node));
1547             Write_Str_With_Col_Check (" with ");
1548
1549             if Null_Record_Present (Node) then
1550                Write_Str_With_Col_Check ("null record");
1551             else
1552                if Present (Expressions (Node)) then
1553                   Sprint_Comma_List (Expressions (Node));
1554
1555                   if Present (Component_Associations (Node)) then
1556                      Write_Str (", ");
1557                   end if;
1558                end if;
1559
1560                if Present (Component_Associations (Node)) then
1561                   Sprint_Comma_List (Component_Associations (Node));
1562                end if;
1563             end if;
1564
1565             Write_Char (')');
1566
1567          when N_Floating_Point_Definition =>
1568             Write_Str_With_Col_Check_Sloc ("digits ");
1569             Sprint_Node (Digits_Expression (Node));
1570             Sprint_Opt_Node (Real_Range_Specification (Node));
1571
1572          when N_Formal_Decimal_Fixed_Point_Definition =>
1573             Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1574
1575          when N_Formal_Derived_Type_Definition =>
1576             Write_Str_With_Col_Check_Sloc ("new ");
1577             Sprint_Node (Subtype_Mark (Node));
1578
1579             if Private_Present (Node) then
1580                Write_Str_With_Col_Check (" with private");
1581             end if;
1582
1583          when N_Formal_Abstract_Subprogram_Declaration =>
1584             Write_Indent_Str_Sloc ("with ");
1585             Sprint_Node (Specification (Node));
1586
1587             Write_Str_With_Col_Check (" is abstract");
1588
1589             if Box_Present (Node) then
1590                Write_Str_With_Col_Check (" <>");
1591             elsif Present (Default_Name (Node)) then
1592                Write_Str_With_Col_Check (" ");
1593                Sprint_Node (Default_Name (Node));
1594             end if;
1595
1596             Write_Char (';');
1597
1598          when N_Formal_Concrete_Subprogram_Declaration =>
1599             Write_Indent_Str_Sloc ("with ");
1600             Sprint_Node (Specification (Node));
1601
1602             if Box_Present (Node) then
1603                Write_Str_With_Col_Check (" is <>");
1604             elsif Present (Default_Name (Node)) then
1605                Write_Str_With_Col_Check (" is ");
1606                Sprint_Node (Default_Name (Node));
1607             end if;
1608
1609             Write_Char (';');
1610
1611          when N_Formal_Discrete_Type_Definition =>
1612             Write_Str_With_Col_Check_Sloc ("<>");
1613
1614          when N_Formal_Floating_Point_Definition =>
1615             Write_Str_With_Col_Check_Sloc ("digits <>");
1616
1617          when N_Formal_Modular_Type_Definition =>
1618             Write_Str_With_Col_Check_Sloc ("mod <>");
1619
1620          when N_Formal_Object_Declaration =>
1621             Set_Debug_Sloc;
1622
1623             if Write_Indent_Identifiers (Node) then
1624                Write_Str (" : ");
1625
1626                if In_Present (Node) then
1627                   Write_Str_With_Col_Check ("in ");
1628                end if;
1629
1630                if Out_Present (Node) then
1631                   Write_Str_With_Col_Check ("out ");
1632                end if;
1633
1634                if Present (Subtype_Mark (Node)) then
1635
1636                   --  Ada 2005 (AI-423): Formal object with null exclusion
1637
1638                   if Null_Exclusion_Present (Node) then
1639                      Write_Str ("not null ");
1640                   end if;
1641
1642                   Sprint_Node (Subtype_Mark (Node));
1643
1644                --  Ada 2005 (AI-423): Formal object with access definition
1645
1646                else
1647                   pragma Assert (Present (Access_Definition (Node)));
1648
1649                   Sprint_Node (Access_Definition (Node));
1650                end if;
1651
1652                if Present (Default_Expression (Node)) then
1653                   Write_Str (" := ");
1654                   Sprint_Node (Default_Expression (Node));
1655                end if;
1656
1657                Write_Char (';');
1658             end if;
1659
1660          when N_Formal_Ordinary_Fixed_Point_Definition =>
1661             Write_Str_With_Col_Check_Sloc ("delta <>");
1662
1663          when N_Formal_Package_Declaration =>
1664             Write_Indent_Str_Sloc ("with package ");
1665             Write_Id (Defining_Identifier (Node));
1666             Write_Str_With_Col_Check (" is new ");
1667             Sprint_Node (Name (Node));
1668             Write_Str_With_Col_Check (" (<>);");
1669
1670          when N_Formal_Private_Type_Definition =>
1671             if Abstract_Present (Node) then
1672                Write_Str_With_Col_Check ("abstract ");
1673             end if;
1674
1675             if Tagged_Present (Node) then
1676                Write_Str_With_Col_Check ("tagged ");
1677             end if;
1678
1679             if Limited_Present (Node) then
1680                Write_Str_With_Col_Check ("limited ");
1681             end if;
1682
1683             Write_Str_With_Col_Check_Sloc ("private");
1684
1685          when N_Formal_Signed_Integer_Type_Definition =>
1686             Write_Str_With_Col_Check_Sloc ("range <>");
1687
1688          when N_Formal_Type_Declaration =>
1689             Write_Indent_Str_Sloc ("type ");
1690             Write_Id (Defining_Identifier (Node));
1691
1692             if Present (Discriminant_Specifications (Node)) then
1693                Write_Discr_Specs (Node);
1694             elsif Unknown_Discriminants_Present (Node) then
1695                Write_Str_With_Col_Check ("(<>)");
1696             end if;
1697
1698             Write_Str_With_Col_Check (" is ");
1699             Sprint_Node (Formal_Type_Definition (Node));
1700             Write_Char (';');
1701
1702          when N_Free_Statement =>
1703             Write_Indent_Str_Sloc ("free ");
1704             Sprint_Node (Expression (Node));
1705             Write_Char (';');
1706
1707          when N_Freeze_Entity =>
1708             if Dump_Original_Only then
1709                null;
1710
1711             elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1712                Write_Indent;
1713                Write_Rewrite_Str ("<<<");
1714                Write_Str_With_Col_Check_Sloc ("freeze ");
1715                Write_Id (Entity (Node));
1716                Write_Str (" [");
1717
1718                if No (Actions (Node)) then
1719                   Write_Char (']');
1720
1721                else
1722                   --  Output freeze actions. We increment Freeze_Indent during
1723                   --  this output to avoid generating extra blank lines before
1724                   --  any procedures included in the freeze actions.
1725
1726                   Freeze_Indent := Freeze_Indent + 1;
1727                   Sprint_Indented_List (Actions (Node));
1728                   Freeze_Indent := Freeze_Indent - 1;
1729                   Write_Indent_Str ("]");
1730                end if;
1731
1732                Write_Rewrite_Str (">>>");
1733             end if;
1734
1735          when N_Full_Type_Declaration =>
1736             Write_Indent_Str_Sloc ("type ");
1737             Sprint_Node (Defining_Identifier (Node));
1738             Write_Discr_Specs (Node);
1739             Write_Str_With_Col_Check (" is ");
1740             Sprint_Node (Type_Definition (Node));
1741             Write_Char (';');
1742
1743          when N_Function_Call =>
1744             Set_Debug_Sloc;
1745             Note_Implicit_Run_Time_Call (Name (Node));
1746             Sprint_Node (Name (Node));
1747             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1748
1749          when N_Function_Instantiation =>
1750             Write_Indent_Str_Sloc ("function ");
1751             Sprint_Node (Defining_Unit_Name (Node));
1752             Write_Str_With_Col_Check (" is new ");
1753             Sprint_Node (Name (Node));
1754             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1755             Write_Char (';');
1756
1757          when N_Function_Specification =>
1758             Write_Str_With_Col_Check_Sloc ("function ");
1759             Sprint_Node (Defining_Unit_Name (Node));
1760             Write_Param_Specs (Node);
1761             Write_Str_With_Col_Check (" return ");
1762
1763             --  Ada 2005 (AI-231)
1764
1765             if Nkind (Result_Definition (Node)) /= N_Access_Definition
1766               and then Null_Exclusion_Present (Node)
1767             then
1768                Write_Str (" not null ");
1769             end if;
1770
1771             Sprint_Node (Result_Definition (Node));
1772
1773          when N_Generic_Association =>
1774             Set_Debug_Sloc;
1775
1776             if Present (Selector_Name (Node)) then
1777                Sprint_Node (Selector_Name (Node));
1778                Write_Str (" => ");
1779             end if;
1780
1781             Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1782
1783          when N_Generic_Function_Renaming_Declaration =>
1784             Write_Indent_Str_Sloc ("generic function ");
1785             Sprint_Node (Defining_Unit_Name (Node));
1786             Write_Str_With_Col_Check (" renames ");
1787             Sprint_Node (Name (Node));
1788             Write_Char (';');
1789
1790          when N_Generic_Package_Declaration =>
1791             Extra_Blank_Line;
1792             Write_Indent_Str_Sloc ("generic ");
1793             Sprint_Indented_List (Generic_Formal_Declarations (Node));
1794             Write_Indent;
1795             Sprint_Node (Specification (Node));
1796             Write_Char (';');
1797
1798          when N_Generic_Package_Renaming_Declaration =>
1799             Write_Indent_Str_Sloc ("generic package ");
1800             Sprint_Node (Defining_Unit_Name (Node));
1801             Write_Str_With_Col_Check (" renames ");
1802             Sprint_Node (Name (Node));
1803             Write_Char (';');
1804
1805          when N_Generic_Procedure_Renaming_Declaration =>
1806             Write_Indent_Str_Sloc ("generic procedure ");
1807             Sprint_Node (Defining_Unit_Name (Node));
1808             Write_Str_With_Col_Check (" renames ");
1809             Sprint_Node (Name (Node));
1810             Write_Char (';');
1811
1812          when N_Generic_Subprogram_Declaration =>
1813             Extra_Blank_Line;
1814             Write_Indent_Str_Sloc ("generic ");
1815             Sprint_Indented_List (Generic_Formal_Declarations (Node));
1816             Write_Indent;
1817             Sprint_Node (Specification (Node));
1818             Write_Char (';');
1819
1820          when N_Goto_Statement =>
1821             Write_Indent_Str_Sloc ("goto ");
1822             Sprint_Node (Name (Node));
1823             Write_Char (';');
1824
1825             if Nkind (Next (Node)) = N_Label then
1826                Write_Indent;
1827             end if;
1828
1829          when N_Handled_Sequence_Of_Statements =>
1830             Set_Debug_Sloc;
1831             Sprint_Indented_List (Statements (Node));
1832
1833             if Present (Exception_Handlers (Node)) then
1834                Write_Indent_Str ("exception");
1835                Indent_Begin;
1836                Sprint_Node_List (Exception_Handlers (Node));
1837                Indent_End;
1838             end if;
1839
1840             if Present (At_End_Proc (Node)) then
1841                Write_Indent_Str ("at end");
1842                Indent_Begin;
1843                Write_Indent;
1844                Sprint_Node (At_End_Proc (Node));
1845                Write_Char (';');
1846                Indent_End;
1847             end if;
1848
1849          when N_Identifier =>
1850             Set_Debug_Sloc;
1851             Write_Id (Node);
1852
1853          when N_If_Statement =>
1854             Write_Indent_Str_Sloc ("if ");
1855             Sprint_Node (Condition (Node));
1856             Write_Str_With_Col_Check (" then");
1857             Sprint_Indented_List (Then_Statements (Node));
1858             Sprint_Opt_Node_List (Elsif_Parts (Node));
1859
1860             if Present (Else_Statements (Node)) then
1861                Write_Indent_Str ("else");
1862                Sprint_Indented_List (Else_Statements (Node));
1863             end if;
1864
1865             Write_Indent_Str ("end if;");
1866
1867          when N_Implicit_Label_Declaration =>
1868             if not Dump_Original_Only then
1869                Write_Indent;
1870                Write_Rewrite_Str ("<<<");
1871                Set_Debug_Sloc;
1872                Write_Id (Defining_Identifier (Node));
1873                Write_Str (" : ");
1874                Write_Str_With_Col_Check ("label");
1875                Write_Rewrite_Str (">>>");
1876             end if;
1877
1878          when N_In =>
1879             Sprint_Left_Opnd (Node);
1880             Write_Str_Sloc (" in ");
1881             Sprint_Right_Opnd (Node);
1882
1883          when N_Incomplete_Type_Declaration =>
1884             Write_Indent_Str_Sloc ("type ");
1885             Write_Id (Defining_Identifier (Node));
1886
1887             if Present (Discriminant_Specifications (Node)) then
1888                Write_Discr_Specs (Node);
1889             elsif Unknown_Discriminants_Present (Node) then
1890                Write_Str_With_Col_Check ("(<>)");
1891             end if;
1892
1893             Write_Char (';');
1894
1895          when N_Index_Or_Discriminant_Constraint =>
1896             Set_Debug_Sloc;
1897             Sprint_Paren_Comma_List (Constraints (Node));
1898
1899          when N_Indexed_Component =>
1900             Sprint_Node_Sloc (Prefix (Node));
1901             Sprint_Opt_Paren_Comma_List (Expressions (Node));
1902
1903          when N_Integer_Literal =>
1904             if Print_In_Hex (Node) then
1905                Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1906             else
1907                Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1908             end if;
1909
1910          when N_Iteration_Scheme =>
1911             if Present (Condition (Node)) then
1912                Write_Str_With_Col_Check_Sloc ("while ");
1913                Sprint_Node (Condition (Node));
1914             else
1915                Write_Str_With_Col_Check_Sloc ("for ");
1916                Sprint_Node (Loop_Parameter_Specification (Node));
1917             end if;
1918
1919             Write_Char (' ');
1920
1921          when N_Itype_Reference =>
1922             Write_Indent_Str_Sloc ("reference ");
1923             Write_Id (Itype (Node));
1924
1925          when N_Label =>
1926             Write_Indent_Str_Sloc ("<<");
1927             Write_Id (Identifier (Node));
1928             Write_Str (">>");
1929
1930          when N_Loop_Parameter_Specification =>
1931             Set_Debug_Sloc;
1932             Write_Id (Defining_Identifier (Node));
1933             Write_Str_With_Col_Check (" in ");
1934
1935             if Reverse_Present (Node) then
1936                Write_Str_With_Col_Check ("reverse ");
1937             end if;
1938
1939             Sprint_Node (Discrete_Subtype_Definition (Node));
1940
1941          when N_Loop_Statement =>
1942             Write_Indent;
1943
1944             if Present (Identifier (Node))
1945               and then (not Has_Created_Identifier (Node)
1946                           or else not Dump_Original_Only)
1947             then
1948                Write_Rewrite_Str ("<<<");
1949                Write_Id (Identifier (Node));
1950                Write_Str (" : ");
1951                Write_Rewrite_Str (">>>");
1952                Sprint_Node (Iteration_Scheme (Node));
1953                Write_Str_With_Col_Check_Sloc ("loop");
1954                Sprint_Indented_List (Statements (Node));
1955                Write_Indent_Str ("end loop ");
1956                Write_Rewrite_Str ("<<<");
1957                Write_Id (Identifier (Node));
1958                Write_Rewrite_Str (">>>");
1959                Write_Char (';');
1960
1961             else
1962                Sprint_Node (Iteration_Scheme (Node));
1963                Write_Str_With_Col_Check_Sloc ("loop");
1964                Sprint_Indented_List (Statements (Node));
1965                Write_Indent_Str ("end loop;");
1966             end if;
1967
1968          when N_Mod_Clause =>
1969             Sprint_Node_List (Pragmas_Before (Node));
1970             Write_Str_With_Col_Check_Sloc ("at mod ");
1971             Sprint_Node (Expression (Node));
1972
1973          when N_Modular_Type_Definition =>
1974             Write_Str_With_Col_Check_Sloc ("mod ");
1975             Sprint_Node (Expression (Node));
1976
1977          when N_Not_In =>
1978             Sprint_Left_Opnd (Node);
1979             Write_Str_Sloc (" not in ");
1980             Sprint_Right_Opnd (Node);
1981
1982          when N_Null =>
1983             Write_Str_With_Col_Check_Sloc ("null");
1984
1985          when N_Null_Statement =>
1986             if Comes_From_Source (Node)
1987               or else Dump_Freeze_Null
1988               or else not Is_List_Member (Node)
1989               or else (No (Prev (Node)) and then No (Next (Node)))
1990             then
1991                Write_Indent_Str_Sloc ("null;");
1992             end if;
1993
1994          when N_Number_Declaration =>
1995             Set_Debug_Sloc;
1996
1997             if Write_Indent_Identifiers (Node) then
1998                Write_Str_With_Col_Check (" : constant ");
1999                Write_Str (" := ");
2000                Sprint_Node (Expression (Node));
2001                Write_Char (';');
2002             end if;
2003
2004          when N_Object_Declaration =>
2005             Set_Debug_Sloc;
2006
2007             if Write_Indent_Identifiers (Node) then
2008                Write_Str_With_Col_Check (" : ");
2009
2010                if Is_Statically_Allocated (Defining_Identifier (Node)) then
2011                   Write_Str_With_Col_Check ("static ");
2012                end if;
2013
2014                if Aliased_Present (Node) then
2015                   Write_Str_With_Col_Check ("aliased ");
2016                end if;
2017
2018                if Constant_Present (Node) then
2019                   Write_Str_With_Col_Check ("constant ");
2020                end if;
2021
2022                --  Ada 2005 (AI-231)
2023
2024                if Null_Exclusion_Present (Node) then
2025                   Write_Str_With_Col_Check ("not null ");
2026                end if;
2027
2028                Sprint_Node (Object_Definition (Node));
2029
2030                if Present (Expression (Node)) then
2031                   Write_Str (" := ");
2032                   Sprint_Node (Expression (Node));
2033                end if;
2034
2035                Write_Char (';');
2036             end if;
2037
2038          when N_Object_Renaming_Declaration =>
2039             Write_Indent;
2040             Set_Debug_Sloc;
2041             Sprint_Node (Defining_Identifier (Node));
2042             Write_Str (" : ");
2043
2044             --  Ada 2005 (AI-230): Access renamings
2045
2046             if Present (Access_Definition (Node)) then
2047                Sprint_Node (Access_Definition (Node));
2048
2049             elsif Present (Subtype_Mark (Node)) then
2050
2051                --  Ada 2005 (AI-423): Object renaming with a null exclusion
2052
2053                if Null_Exclusion_Present (Node) then
2054                   Write_Str ("not null ");
2055                end if;
2056
2057                Sprint_Node (Subtype_Mark (Node));
2058
2059             else
2060                Write_Str (" ??? ");
2061             end if;
2062
2063             Write_Str_With_Col_Check (" renames ");
2064             Sprint_Node (Name (Node));
2065             Write_Char (';');
2066
2067          when N_Op_Abs =>
2068             Write_Operator (Node, "abs ");
2069             Sprint_Right_Opnd (Node);
2070
2071          when N_Op_Add =>
2072             Sprint_Left_Opnd (Node);
2073             Write_Operator (Node, " + ");
2074             Sprint_Right_Opnd (Node);
2075
2076          when N_Op_And =>
2077             Sprint_Left_Opnd (Node);
2078             Write_Operator (Node, " and ");
2079             Sprint_Right_Opnd (Node);
2080
2081          when N_Op_Concat =>
2082             Sprint_Left_Opnd (Node);
2083             Write_Operator (Node, " & ");
2084             Sprint_Right_Opnd (Node);
2085
2086          when N_Op_Divide =>
2087             Sprint_Left_Opnd (Node);
2088             Write_Char (' ');
2089             Process_TFAI_RR_Flags (Node);
2090             Write_Operator (Node, "/ ");
2091             Sprint_Right_Opnd (Node);
2092
2093          when N_Op_Eq =>
2094             Sprint_Left_Opnd (Node);
2095             Write_Operator (Node, " = ");
2096             Sprint_Right_Opnd (Node);
2097
2098          when N_Op_Expon =>
2099             Sprint_Left_Opnd (Node);
2100             Write_Operator (Node, " ** ");
2101             Sprint_Right_Opnd (Node);
2102
2103          when N_Op_Ge =>
2104             Sprint_Left_Opnd (Node);
2105             Write_Operator (Node, " >= ");
2106             Sprint_Right_Opnd (Node);
2107
2108          when N_Op_Gt =>
2109             Sprint_Left_Opnd (Node);
2110             Write_Operator (Node, " > ");
2111             Sprint_Right_Opnd (Node);
2112
2113          when N_Op_Le =>
2114             Sprint_Left_Opnd (Node);
2115             Write_Operator (Node, " <= ");
2116             Sprint_Right_Opnd (Node);
2117
2118          when N_Op_Lt =>
2119             Sprint_Left_Opnd (Node);
2120             Write_Operator (Node, " < ");
2121             Sprint_Right_Opnd (Node);
2122
2123          when N_Op_Minus =>
2124             Write_Operator (Node, "-");
2125             Sprint_Right_Opnd (Node);
2126
2127          when N_Op_Mod =>
2128             Sprint_Left_Opnd (Node);
2129
2130             if Treat_Fixed_As_Integer (Node) then
2131                Write_Str (" #");
2132             end if;
2133
2134             Write_Operator (Node, " mod ");
2135             Sprint_Right_Opnd (Node);
2136
2137          when N_Op_Multiply =>
2138             Sprint_Left_Opnd (Node);
2139             Write_Char (' ');
2140             Process_TFAI_RR_Flags (Node);
2141             Write_Operator (Node, "* ");
2142             Sprint_Right_Opnd (Node);
2143
2144          when N_Op_Ne =>
2145             Sprint_Left_Opnd (Node);
2146             Write_Operator (Node, " /= ");
2147             Sprint_Right_Opnd (Node);
2148
2149          when N_Op_Not =>
2150             Write_Operator (Node, "not ");
2151             Sprint_Right_Opnd (Node);
2152
2153          when N_Op_Or =>
2154             Sprint_Left_Opnd (Node);
2155             Write_Operator (Node, " or ");
2156             Sprint_Right_Opnd (Node);
2157
2158          when N_Op_Plus =>
2159             Write_Operator (Node, "+");
2160             Sprint_Right_Opnd (Node);
2161
2162          when N_Op_Rem =>
2163             Sprint_Left_Opnd (Node);
2164
2165             if Treat_Fixed_As_Integer (Node) then
2166                Write_Str (" #");
2167             end if;
2168
2169             Write_Operator (Node, " rem ");
2170             Sprint_Right_Opnd (Node);
2171
2172          when N_Op_Shift =>
2173             Set_Debug_Sloc;
2174             Write_Id (Node);
2175             Write_Char ('!');
2176             Write_Str_With_Col_Check ("(");
2177             Sprint_Node (Left_Opnd (Node));
2178             Write_Str (", ");
2179             Sprint_Node (Right_Opnd (Node));
2180             Write_Char (')');
2181
2182          when N_Op_Subtract =>
2183             Sprint_Left_Opnd (Node);
2184             Write_Operator (Node, " - ");
2185             Sprint_Right_Opnd (Node);
2186
2187          when N_Op_Xor =>
2188             Sprint_Left_Opnd (Node);
2189             Write_Operator (Node, " xor ");
2190             Sprint_Right_Opnd (Node);
2191
2192          when N_Operator_Symbol =>
2193             Write_Name_With_Col_Check_Sloc (Chars (Node));
2194
2195          when N_Ordinary_Fixed_Point_Definition =>
2196             Write_Str_With_Col_Check_Sloc ("delta ");
2197             Sprint_Node (Delta_Expression (Node));
2198             Sprint_Opt_Node (Real_Range_Specification (Node));
2199
2200          when N_Or_Else =>
2201             Sprint_Left_Opnd (Node);
2202             Write_Str_Sloc (" or else ");
2203             Sprint_Right_Opnd (Node);
2204
2205          when N_Others_Choice =>
2206             if All_Others (Node) then
2207                Write_Str_With_Col_Check ("all ");
2208             end if;
2209
2210             Write_Str_With_Col_Check_Sloc ("others");
2211
2212          when N_Package_Body =>
2213             Extra_Blank_Line;
2214             Write_Indent_Str_Sloc ("package body ");
2215             Sprint_Node (Defining_Unit_Name (Node));
2216             Write_Str (" is");
2217             Sprint_Indented_List (Declarations (Node));
2218
2219             if Present (Handled_Statement_Sequence (Node)) then
2220                Write_Indent_Str ("begin");
2221                Sprint_Node (Handled_Statement_Sequence (Node));
2222             end if;
2223
2224             Write_Indent_Str ("end ");
2225             Sprint_End_Label
2226               (Handled_Statement_Sequence (Node), Defining_Unit_Name (Node));
2227             Write_Char (';');
2228
2229          when N_Package_Body_Stub =>
2230             Write_Indent_Str_Sloc ("package body ");
2231             Sprint_Node (Defining_Identifier (Node));
2232             Write_Str_With_Col_Check (" is separate;");
2233
2234          when N_Package_Declaration =>
2235             Extra_Blank_Line;
2236             Write_Indent;
2237             Sprint_Node_Sloc (Specification (Node));
2238             Write_Char (';');
2239
2240          when N_Package_Instantiation =>
2241             Extra_Blank_Line;
2242             Write_Indent_Str_Sloc ("package ");
2243             Sprint_Node (Defining_Unit_Name (Node));
2244             Write_Str (" is new ");
2245             Sprint_Node (Name (Node));
2246             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2247             Write_Char (';');
2248
2249          when N_Package_Renaming_Declaration =>
2250             Write_Indent_Str_Sloc ("package ");
2251             Sprint_Node (Defining_Unit_Name (Node));
2252             Write_Str_With_Col_Check (" renames ");
2253             Sprint_Node (Name (Node));
2254             Write_Char (';');
2255
2256          when N_Package_Specification =>
2257             Write_Str_With_Col_Check_Sloc ("package ");
2258             Sprint_Node (Defining_Unit_Name (Node));
2259             Write_Str (" is");
2260             Sprint_Indented_List (Visible_Declarations (Node));
2261
2262             if Present (Private_Declarations (Node)) then
2263                Write_Indent_Str ("private");
2264                Sprint_Indented_List (Private_Declarations (Node));
2265             end if;
2266
2267             Write_Indent_Str ("end ");
2268             Sprint_Node (Defining_Unit_Name (Node));
2269
2270          when N_Parameter_Association =>
2271             Sprint_Node_Sloc (Selector_Name (Node));
2272             Write_Str (" => ");
2273             Sprint_Node (Explicit_Actual_Parameter (Node));
2274
2275          when N_Parameter_Specification =>
2276             Set_Debug_Sloc;
2277
2278             if Write_Identifiers (Node) then
2279                Write_Str (" : ");
2280
2281                if In_Present (Node) then
2282                   Write_Str_With_Col_Check ("in ");
2283                end if;
2284
2285                if Out_Present (Node) then
2286                   Write_Str_With_Col_Check ("out ");
2287                end if;
2288
2289                --  Ada 2005 (AI-231) parameter specification may carry
2290                --  null exclusion. Do not print it now if this is an
2291                --  access parameter, it is emitted when the access
2292                --  definition is displayed.
2293
2294                if Null_Exclusion_Present (Node)
2295                  and then Nkind (Parameter_Type (Node))
2296                    /= N_Access_Definition
2297                then
2298                   Write_Str ("not null ");
2299                end if;
2300
2301                Sprint_Node (Parameter_Type (Node));
2302
2303                if Present (Expression (Node)) then
2304                   Write_Str (" := ");
2305                   Sprint_Node (Expression (Node));
2306                end if;
2307             else
2308                Write_Str (", ");
2309             end if;
2310
2311          when N_Pop_Constraint_Error_Label =>
2312             Write_Indent_Str ("%pop_constraint_error_label");
2313
2314          when N_Pop_Program_Error_Label =>
2315             Write_Indent_Str ("%pop_program_error_label");
2316
2317          when N_Pop_Storage_Error_Label =>
2318             Write_Indent_Str ("%pop_storage_error_label");
2319
2320          when N_Push_Constraint_Error_Label =>
2321             Write_Indent_Str ("%push_constraint_error_label (");
2322
2323             if Present (Exception_Label (Node)) then
2324                Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2325             end if;
2326
2327             Write_Str (")");
2328
2329          when N_Push_Program_Error_Label =>
2330             Write_Indent_Str ("%push_program_error_label (");
2331
2332             if Present (Exception_Label (Node)) then
2333                Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2334             end if;
2335
2336             Write_Str (")");
2337
2338          when N_Push_Storage_Error_Label =>
2339             Write_Indent_Str ("%push_storage_error_label (");
2340
2341             if Present (Exception_Label (Node)) then
2342                Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2343             end if;
2344
2345             Write_Str (")");
2346
2347          when N_Pragma =>
2348             Write_Indent_Str_Sloc ("pragma ");
2349             Write_Name_With_Col_Check (Chars (Node));
2350
2351             if Present (Pragma_Argument_Associations (Node)) then
2352                Sprint_Opt_Paren_Comma_List
2353                  (Pragma_Argument_Associations (Node));
2354             end if;
2355
2356             Write_Char (';');
2357
2358          when N_Pragma_Argument_Association =>
2359             Set_Debug_Sloc;
2360
2361             if Chars (Node) /= No_Name then
2362                Write_Name_With_Col_Check (Chars (Node));
2363                Write_Str (" => ");
2364             end if;
2365
2366             Sprint_Node (Expression (Node));
2367
2368          when N_Private_Type_Declaration =>
2369             Write_Indent_Str_Sloc ("type ");
2370             Write_Id (Defining_Identifier (Node));
2371
2372             if Present (Discriminant_Specifications (Node)) then
2373                Write_Discr_Specs (Node);
2374             elsif Unknown_Discriminants_Present (Node) then
2375                Write_Str_With_Col_Check ("(<>)");
2376             end if;
2377
2378             Write_Str (" is ");
2379
2380             if Tagged_Present (Node) then
2381                Write_Str_With_Col_Check ("tagged ");
2382             end if;
2383
2384             if Limited_Present (Node) then
2385                Write_Str_With_Col_Check ("limited ");
2386             end if;
2387
2388             Write_Str_With_Col_Check ("private;");
2389
2390          when N_Private_Extension_Declaration =>
2391             Write_Indent_Str_Sloc ("type ");
2392             Write_Id (Defining_Identifier (Node));
2393
2394             if Present (Discriminant_Specifications (Node)) then
2395                Write_Discr_Specs (Node);
2396             elsif Unknown_Discriminants_Present (Node) then
2397                Write_Str_With_Col_Check ("(<>)");
2398             end if;
2399
2400             Write_Str_With_Col_Check (" is new ");
2401             Sprint_Node (Subtype_Indication (Node));
2402             Write_Str_With_Col_Check (" with private;");
2403
2404          when N_Procedure_Call_Statement =>
2405             Write_Indent;
2406             Set_Debug_Sloc;
2407             Note_Implicit_Run_Time_Call (Name (Node));
2408             Sprint_Node (Name (Node));
2409             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2410             Write_Char (';');
2411
2412          when N_Procedure_Instantiation =>
2413             Write_Indent_Str_Sloc ("procedure ");
2414             Sprint_Node (Defining_Unit_Name (Node));
2415             Write_Str_With_Col_Check (" is new ");
2416             Sprint_Node (Name (Node));
2417             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2418             Write_Char (';');
2419
2420          when N_Procedure_Specification =>
2421             Write_Str_With_Col_Check_Sloc ("procedure ");
2422             Sprint_Node (Defining_Unit_Name (Node));
2423             Write_Param_Specs (Node);
2424
2425          when N_Protected_Body =>
2426             Write_Indent_Str_Sloc ("protected body ");
2427             Write_Id (Defining_Identifier (Node));
2428             Write_Str (" is");
2429             Sprint_Indented_List (Declarations (Node));
2430             Write_Indent_Str ("end ");
2431             Write_Id (Defining_Identifier (Node));
2432             Write_Char (';');
2433
2434          when N_Protected_Body_Stub =>
2435             Write_Indent_Str_Sloc ("protected body ");
2436             Write_Id (Defining_Identifier (Node));
2437             Write_Str_With_Col_Check (" is separate;");
2438
2439          when N_Protected_Definition =>
2440             Set_Debug_Sloc;
2441             Sprint_Indented_List (Visible_Declarations (Node));
2442
2443             if Present (Private_Declarations (Node)) then
2444                Write_Indent_Str ("private");
2445                Sprint_Indented_List (Private_Declarations (Node));
2446             end if;
2447
2448             Write_Indent_Str ("end ");
2449
2450          when N_Protected_Type_Declaration =>
2451             Write_Indent_Str_Sloc ("protected type ");
2452             Sprint_Node (Defining_Identifier (Node));
2453             Write_Discr_Specs (Node);
2454
2455             if Present (Interface_List (Node)) then
2456                Write_Str (" is new ");
2457                Sprint_And_List (Interface_List (Node));
2458                Write_Str (" with ");
2459             else
2460                Write_Str (" is");
2461             end if;
2462
2463             Sprint_Node (Protected_Definition (Node));
2464             Write_Id (Defining_Identifier (Node));
2465             Write_Char (';');
2466
2467          when N_Qualified_Expression =>
2468             Sprint_Node (Subtype_Mark (Node));
2469             Write_Char_Sloc (''');
2470
2471             --  Print expression, make sure we have at least one level of
2472             --  parentheses around the expression. For cases of qualified
2473             --  expressions in the source, this is always the case, but
2474             --  for generated qualifications, there may be no explicit
2475             --  parentheses present.
2476
2477             if Paren_Count (Expression (Node)) /= 0 then
2478                Sprint_Node (Expression (Node));
2479             else
2480                Write_Char ('(');
2481                Sprint_Node (Expression (Node));
2482                Write_Char (')');
2483             end if;
2484
2485          when N_Raise_Constraint_Error =>
2486
2487             --  This node can be used either as a subexpression or as a
2488             --  statement form. The following test is a reasonably reliable
2489             --  way to distinguish the two cases.
2490
2491             if Is_List_Member (Node)
2492               and then Nkind (Parent (Node)) not in N_Subexpr
2493             then
2494                Write_Indent;
2495             end if;
2496
2497             Write_Str_With_Col_Check_Sloc ("[constraint_error");
2498             Write_Condition_And_Reason (Node);
2499
2500          when N_Raise_Program_Error =>
2501
2502             --  This node can be used either as a subexpression or as a
2503             --  statement form. The following test is a reasonably reliable
2504             --  way to distinguish the two cases.
2505
2506             if Is_List_Member (Node)
2507               and then Nkind (Parent (Node)) not in N_Subexpr
2508             then
2509                Write_Indent;
2510             end if;
2511
2512             Write_Str_With_Col_Check_Sloc ("[program_error");
2513             Write_Condition_And_Reason (Node);
2514
2515          when N_Raise_Storage_Error =>
2516
2517             --  This node can be used either as a subexpression or as a
2518             --  statement form. The following test is a reasonably reliable
2519             --  way to distinguish the two cases.
2520
2521             if Is_List_Member (Node)
2522               and then Nkind (Parent (Node)) not in N_Subexpr
2523             then
2524                Write_Indent;
2525             end if;
2526
2527             Write_Str_With_Col_Check_Sloc ("[storage_error");
2528             Write_Condition_And_Reason (Node);
2529
2530          when N_Raise_Statement =>
2531             Write_Indent_Str_Sloc ("raise ");
2532             Sprint_Node (Name (Node));
2533             Write_Char (';');
2534
2535          when N_Range =>
2536             Sprint_Node (Low_Bound (Node));
2537             Write_Str_Sloc (" .. ");
2538             Sprint_Node (High_Bound (Node));
2539             Update_Itype (Node);
2540
2541          when N_Range_Constraint =>
2542             Write_Str_With_Col_Check_Sloc ("range ");
2543             Sprint_Node (Range_Expression (Node));
2544
2545          when N_Real_Literal =>
2546             Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2547
2548          when N_Real_Range_Specification =>
2549             Write_Str_With_Col_Check_Sloc ("range ");
2550             Sprint_Node (Low_Bound (Node));
2551             Write_Str (" .. ");
2552             Sprint_Node (High_Bound (Node));
2553
2554          when N_Record_Definition =>
2555             if Abstract_Present (Node) then
2556                Write_Str_With_Col_Check ("abstract ");
2557             end if;
2558
2559             if Tagged_Present (Node) then
2560                Write_Str_With_Col_Check ("tagged ");
2561             end if;
2562
2563             if Limited_Present (Node) then
2564                Write_Str_With_Col_Check ("limited ");
2565             end if;
2566
2567             if Null_Present (Node) then
2568                Write_Str_With_Col_Check_Sloc ("null record");
2569
2570             else
2571                Write_Str_With_Col_Check_Sloc ("record");
2572                Sprint_Node (Component_List (Node));
2573                Write_Indent_Str ("end record");
2574             end if;
2575
2576          when N_Record_Representation_Clause =>
2577             Write_Indent_Str_Sloc ("for ");
2578             Sprint_Node (Identifier (Node));
2579             Write_Str_With_Col_Check (" use record ");
2580
2581             if Present (Mod_Clause (Node)) then
2582                Sprint_Node (Mod_Clause (Node));
2583             end if;
2584
2585             Sprint_Indented_List (Component_Clauses (Node));
2586             Write_Indent_Str ("end record;");
2587
2588          when N_Reference =>
2589             Sprint_Node (Prefix (Node));
2590             Write_Str_With_Col_Check_Sloc ("'reference");
2591
2592          when N_Requeue_Statement =>
2593             Write_Indent_Str_Sloc ("requeue ");
2594             Sprint_Node (Name (Node));
2595
2596             if Abort_Present (Node) then
2597                Write_Str_With_Col_Check (" with abort");
2598             end if;
2599
2600             Write_Char (';');
2601
2602          when N_Return_Statement =>
2603             if Present (Expression (Node)) then
2604                Write_Indent_Str_Sloc ("return ");
2605                Sprint_Node (Expression (Node));
2606                Write_Char (';');
2607             else
2608                Write_Indent_Str_Sloc ("return;");
2609             end if;
2610
2611          when N_Selective_Accept =>
2612             Write_Indent_Str_Sloc ("select");
2613
2614             declare
2615                Alt_Node : Node_Id;
2616             begin
2617                Alt_Node := First (Select_Alternatives (Node));
2618                loop
2619                   Indent_Begin;
2620                   Sprint_Node (Alt_Node);
2621                   Indent_End;
2622                   Next (Alt_Node);
2623                   exit when No (Alt_Node);
2624                   Write_Indent_Str ("or");
2625                end loop;
2626             end;
2627
2628             if Present (Else_Statements (Node)) then
2629                Write_Indent_Str ("else");
2630                Sprint_Indented_List (Else_Statements (Node));
2631             end if;
2632
2633             Write_Indent_Str ("end select;");
2634
2635          when N_Signed_Integer_Type_Definition =>
2636             Write_Str_With_Col_Check_Sloc ("range ");
2637             Sprint_Node (Low_Bound (Node));
2638             Write_Str (" .. ");
2639             Sprint_Node (High_Bound (Node));
2640
2641          when N_Single_Protected_Declaration =>
2642             Write_Indent_Str_Sloc ("protected ");
2643             Write_Id (Defining_Identifier (Node));
2644             Write_Str (" is");
2645             Sprint_Node (Protected_Definition (Node));
2646             Write_Id (Defining_Identifier (Node));
2647             Write_Char (';');
2648
2649          when N_Single_Task_Declaration =>
2650             Write_Indent_Str_Sloc ("task ");
2651             Sprint_Node (Defining_Identifier (Node));
2652
2653             if Present (Task_Definition (Node)) then
2654                Write_Str (" is");
2655                Sprint_Node (Task_Definition (Node));
2656             end if;
2657
2658             Write_Char (';');
2659
2660          when N_Selected_Component =>
2661             Sprint_Node (Prefix (Node));
2662             Write_Char_Sloc ('.');
2663             Sprint_Node (Selector_Name (Node));
2664
2665          when N_Slice =>
2666             Set_Debug_Sloc;
2667             Sprint_Node (Prefix (Node));
2668             Write_Str_With_Col_Check (" (");
2669             Sprint_Node (Discrete_Range (Node));
2670             Write_Char (')');
2671
2672          when N_String_Literal =>
2673             if String_Length (Strval (Node)) + Column > 75 then
2674                Write_Indent_Str ("  ");
2675             end if;
2676
2677             Set_Debug_Sloc;
2678             Write_String_Table_Entry (Strval (Node));
2679
2680          when N_Subprogram_Body =>
2681
2682             --  Output extra blank line unless we are in freeze actions
2683
2684             if Freeze_Indent = 0 then
2685                Extra_Blank_Line;
2686             end if;
2687
2688             Write_Indent;
2689             Sprint_Node_Sloc (Specification (Node));
2690             Write_Str (" is");
2691
2692             Sprint_Indented_List (Declarations (Node));
2693             Write_Indent_Str ("begin");
2694             Sprint_Node (Handled_Statement_Sequence (Node));
2695
2696             Write_Indent_Str ("end ");
2697
2698             Sprint_End_Label
2699               (Handled_Statement_Sequence (Node),
2700                  Defining_Unit_Name (Specification (Node)));
2701             Write_Char (';');
2702
2703             if Is_List_Member (Node)
2704               and then Present (Next (Node))
2705               and then Nkind (Next (Node)) /= N_Subprogram_Body
2706             then
2707                Write_Indent;
2708             end if;
2709
2710          when N_Subprogram_Body_Stub =>
2711             Write_Indent;
2712             Sprint_Node_Sloc (Specification (Node));
2713             Write_Str_With_Col_Check (" is separate;");
2714
2715          when N_Subprogram_Declaration =>
2716             Write_Indent;
2717             Sprint_Node_Sloc (Specification (Node));
2718
2719             if Nkind (Specification (Node)) = N_Procedure_Specification
2720               and then Null_Present (Specification (Node))
2721             then
2722                Write_Str_With_Col_Check (" is null");
2723             end if;
2724
2725             Write_Char (';');
2726
2727          when N_Subprogram_Info =>
2728             Sprint_Node (Identifier (Node));
2729             Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2730
2731          when N_Subprogram_Renaming_Declaration =>
2732             Write_Indent;
2733             Sprint_Node (Specification (Node));
2734             Write_Str_With_Col_Check_Sloc (" renames ");
2735             Sprint_Node (Name (Node));
2736             Write_Char (';');
2737
2738          when N_Subtype_Declaration =>
2739             Write_Indent_Str_Sloc ("subtype ");
2740             Sprint_Node (Defining_Identifier (Node));
2741             Write_Str (" is ");
2742
2743             --  Ada 2005 (AI-231)
2744
2745             if Null_Exclusion_Present (Node) then
2746                Write_Str ("not null ");
2747             end if;
2748
2749             Sprint_Node (Subtype_Indication (Node));
2750             Write_Char (';');
2751
2752          when N_Subtype_Indication =>
2753             Sprint_Node_Sloc (Subtype_Mark (Node));
2754             Write_Char (' ');
2755             Sprint_Node (Constraint (Node));
2756
2757          when N_Subunit =>
2758             Write_Indent_Str_Sloc ("separate (");
2759             Sprint_Node (Name (Node));
2760             Write_Char (')');
2761             Extra_Blank_Line;
2762             Sprint_Node (Proper_Body (Node));
2763
2764          when N_Task_Body =>
2765             Write_Indent_Str_Sloc ("task body ");
2766             Write_Id (Defining_Identifier (Node));
2767             Write_Str (" is");
2768             Sprint_Indented_List (Declarations (Node));
2769             Write_Indent_Str ("begin");
2770             Sprint_Node (Handled_Statement_Sequence (Node));
2771             Write_Indent_Str ("end ");
2772             Sprint_End_Label
2773               (Handled_Statement_Sequence (Node), Defining_Identifier (Node));
2774             Write_Char (';');
2775
2776          when N_Task_Body_Stub =>
2777             Write_Indent_Str_Sloc ("task body ");
2778             Write_Id (Defining_Identifier (Node));
2779             Write_Str_With_Col_Check (" is separate;");
2780
2781          when N_Task_Definition =>
2782             Set_Debug_Sloc;
2783             Sprint_Indented_List (Visible_Declarations (Node));
2784
2785             if Present (Private_Declarations (Node)) then
2786                Write_Indent_Str ("private");
2787                Sprint_Indented_List (Private_Declarations (Node));
2788             end if;
2789
2790             Write_Indent_Str ("end ");
2791             Sprint_End_Label (Node, Defining_Identifier (Parent (Node)));
2792
2793          when N_Task_Type_Declaration =>
2794             Write_Indent_Str_Sloc ("task type ");
2795             Sprint_Node (Defining_Identifier (Node));
2796             Write_Discr_Specs (Node);
2797
2798             if Present (Interface_List (Node)) then
2799                Write_Str (" is new ");
2800                Sprint_And_List (Interface_List (Node));
2801             end if;
2802
2803             if Present (Task_Definition (Node)) then
2804                if No (Interface_List (Node)) then
2805                   Write_Str (" is");
2806                else
2807                   Write_Str (" with ");
2808                end if;
2809
2810                Sprint_Node (Task_Definition (Node));
2811             end if;
2812
2813             Write_Char (';');
2814
2815          when N_Terminate_Alternative =>
2816             Sprint_Node_List (Pragmas_Before (Node));
2817
2818             Write_Indent;
2819
2820             if Present (Condition (Node)) then
2821                Write_Str_With_Col_Check ("when ");
2822                Sprint_Node (Condition (Node));
2823                Write_Str (" => ");
2824             end if;
2825
2826             Write_Str_With_Col_Check_Sloc ("terminate;");
2827             Sprint_Node_List (Pragmas_After (Node));
2828
2829          when N_Timed_Entry_Call =>
2830             Write_Indent_Str_Sloc ("select");
2831             Indent_Begin;
2832             Sprint_Node (Entry_Call_Alternative (Node));
2833             Indent_End;
2834             Write_Indent_Str ("or");
2835             Indent_Begin;
2836             Sprint_Node (Delay_Alternative (Node));
2837             Indent_End;
2838             Write_Indent_Str ("end select;");
2839
2840          when N_Triggering_Alternative =>
2841             Sprint_Node_List (Pragmas_Before (Node));
2842             Sprint_Node_Sloc (Triggering_Statement (Node));
2843             Sprint_Node_List (Statements (Node));
2844
2845          when N_Type_Conversion =>
2846             Set_Debug_Sloc;
2847             Sprint_Node (Subtype_Mark (Node));
2848             Col_Check (4);
2849
2850             if Conversion_OK (Node) then
2851                Write_Char ('?');
2852             end if;
2853
2854             if Float_Truncate (Node) then
2855                Write_Char ('^');
2856             end if;
2857
2858             if Rounded_Result (Node) then
2859                Write_Char ('@');
2860             end if;
2861
2862             Write_Char ('(');
2863             Sprint_Node (Expression (Node));
2864             Write_Char (')');
2865
2866          when N_Unchecked_Expression =>
2867             Col_Check (10);
2868             Write_Str ("`(");
2869             Sprint_Node_Sloc (Expression (Node));
2870             Write_Char (')');
2871
2872          when N_Unchecked_Type_Conversion =>
2873             Sprint_Node (Subtype_Mark (Node));
2874             Write_Char ('!');
2875             Write_Str_With_Col_Check ("(");
2876             Sprint_Node_Sloc (Expression (Node));
2877             Write_Char (')');
2878
2879          when N_Unconstrained_Array_Definition =>
2880             Write_Str_With_Col_Check_Sloc ("array (");
2881
2882             declare
2883                Node1 : Node_Id;
2884             begin
2885                Node1 := First (Subtype_Marks (Node));
2886                loop
2887                   Sprint_Node (Node1);
2888                   Write_Str_With_Col_Check (" range <>");
2889                   Next (Node1);
2890                   exit when Node1 = Empty;
2891                   Write_Str (", ");
2892                end loop;
2893             end;
2894
2895             Write_Str (") of ");
2896             Sprint_Node (Component_Definition (Node));
2897
2898          when N_Unused_At_Start | N_Unused_At_End =>
2899             Write_Indent_Str ("***** Error, unused node encountered *****");
2900             Write_Eol;
2901
2902          when N_Use_Package_Clause =>
2903             Write_Indent_Str_Sloc ("use ");
2904             Sprint_Comma_List (Names (Node));
2905             Write_Char (';');
2906
2907          when N_Use_Type_Clause =>
2908             Write_Indent_Str_Sloc ("use type ");
2909             Sprint_Comma_List (Subtype_Marks (Node));
2910             Write_Char (';');
2911
2912          when N_Validate_Unchecked_Conversion =>
2913             Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2914             Sprint_Node (Source_Type (Node));
2915             Write_Str (", ");
2916             Sprint_Node (Target_Type (Node));
2917             Write_Str (");");
2918
2919          when N_Variant =>
2920             Write_Indent_Str_Sloc ("when ");
2921             Sprint_Bar_List (Discrete_Choices (Node));
2922             Write_Str (" => ");
2923             Sprint_Node (Component_List (Node));
2924
2925          when N_Variant_Part =>
2926             Indent_Begin;
2927             Write_Indent_Str_Sloc ("case ");
2928             Sprint_Node (Name (Node));
2929             Write_Str (" is ");
2930             Sprint_Indented_List (Variants (Node));
2931             Write_Indent_Str ("end case");
2932             Indent_End;
2933
2934          when N_With_Clause =>
2935
2936             --  Special test, if we are dumping the original tree only,
2937             --  then we want to eliminate the bogus with clauses that
2938             --  correspond to the non-existent children of Text_IO.
2939
2940             if Dump_Original_Only
2941               and then Is_Text_IO_Kludge_Unit (Name (Node))
2942             then
2943                null;
2944
2945             --  Normal case, output the with clause
2946
2947             else
2948                if First_Name (Node) or else not Dump_Original_Only then
2949
2950                   --  Ada 2005 (AI-50217): Print limited with_clauses
2951
2952                   if Private_Present (Node) and Limited_Present (Node) then
2953                      Write_Indent_Str ("limited private with ");
2954
2955                   elsif Private_Present (Node) then
2956                      Write_Indent_Str ("private with ");
2957
2958                   elsif Limited_Present (Node) then
2959                      Write_Indent_Str ("limited with ");
2960
2961                   else
2962                      Write_Indent_Str ("with ");
2963                   end if;
2964
2965                else
2966                   Write_Str (", ");
2967                end if;
2968
2969                Sprint_Node_Sloc (Name (Node));
2970
2971                if Last_Name (Node) or else not Dump_Original_Only then
2972                   Write_Char (';');
2973                end if;
2974             end if;
2975
2976       end case;
2977
2978       if Nkind (Node) in N_Subexpr
2979         and then Do_Range_Check (Node)
2980       then
2981          Write_Str ("}");
2982       end if;
2983
2984       for J in 1 .. Paren_Count (Node) loop
2985          Write_Char (')');
2986       end loop;
2987
2988       Dump_Node := Save_Dump_Node;
2989    end Sprint_Node_Actual;
2990
2991    ----------------------
2992    -- Sprint_Node_List --
2993    ----------------------
2994
2995    procedure Sprint_Node_List (List : List_Id) is
2996       Node : Node_Id;
2997
2998    begin
2999       if Is_Non_Empty_List (List) then
3000          Node := First (List);
3001
3002          loop
3003             Sprint_Node (Node);
3004             Next (Node);
3005             exit when Node = Empty;
3006          end loop;
3007       end if;
3008    end Sprint_Node_List;
3009
3010    ----------------------
3011    -- Sprint_Node_Sloc --
3012    ----------------------
3013
3014    procedure Sprint_Node_Sloc (Node : Node_Id) is
3015    begin
3016       Sprint_Node (Node);
3017
3018       if Debug_Generated_Code and then Present (Dump_Node) then
3019          Set_Sloc (Dump_Node, Sloc (Node));
3020          Dump_Node := Empty;
3021       end if;
3022    end Sprint_Node_Sloc;
3023
3024    ---------------------
3025    -- Sprint_Opt_Node --
3026    ---------------------
3027
3028    procedure Sprint_Opt_Node (Node : Node_Id) is
3029    begin
3030       if Present (Node) then
3031          Write_Char (' ');
3032          Sprint_Node (Node);
3033       end if;
3034    end Sprint_Opt_Node;
3035
3036    --------------------------
3037    -- Sprint_Opt_Node_List --
3038    --------------------------
3039
3040    procedure Sprint_Opt_Node_List (List : List_Id) is
3041    begin
3042       if Present (List) then
3043          Sprint_Node_List (List);
3044       end if;
3045    end Sprint_Opt_Node_List;
3046
3047    ---------------------------------
3048    -- Sprint_Opt_Paren_Comma_List --
3049    ---------------------------------
3050
3051    procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
3052    begin
3053       if Is_Non_Empty_List (List) then
3054          Write_Char (' ');
3055          Sprint_Paren_Comma_List (List);
3056       end if;
3057    end Sprint_Opt_Paren_Comma_List;
3058
3059    -----------------------------
3060    -- Sprint_Paren_Comma_List --
3061    -----------------------------
3062
3063    procedure Sprint_Paren_Comma_List (List : List_Id) is
3064       N           : Node_Id;
3065       Node_Exists : Boolean := False;
3066
3067    begin
3068
3069       if Is_Non_Empty_List (List) then
3070
3071          if Dump_Original_Only then
3072             N := First (List);
3073             while Present (N) loop
3074                if not Is_Rewrite_Insertion (N) then
3075                   Node_Exists := True;
3076                   exit;
3077                end if;
3078
3079                Next (N);
3080             end loop;
3081
3082             if not Node_Exists then
3083                return;
3084             end if;
3085          end if;
3086
3087          Write_Str_With_Col_Check ("(");
3088          Sprint_Comma_List (List);
3089          Write_Char (')');
3090       end if;
3091    end Sprint_Paren_Comma_List;
3092
3093    ----------------------
3094    -- Sprint_Right_Opnd --
3095    ----------------------
3096
3097    procedure Sprint_Right_Opnd (N : Node_Id) is
3098       Opnd : constant Node_Id := Right_Opnd (N);
3099
3100    begin
3101       if Paren_Count (Opnd) /= 0
3102         or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
3103       then
3104          Sprint_Node (Opnd);
3105
3106       else
3107          Write_Char ('(');
3108          Sprint_Node (Opnd);
3109          Write_Char (')');
3110       end if;
3111    end Sprint_Right_Opnd;
3112
3113    ------------------
3114    -- Update_Itype --
3115    ------------------
3116
3117    procedure Update_Itype (Node : Node_Id) is
3118    begin
3119       if Present (Etype (Node))
3120         and then Is_Itype (Etype (Node))
3121         and then Debug_Generated_Code
3122       then
3123          Set_Sloc (Etype (Node), Sloc (Node));
3124       end if;
3125    end Update_Itype;
3126
3127    ---------------------
3128    -- Write_Char_Sloc --
3129    ---------------------
3130
3131    procedure Write_Char_Sloc (C : Character) is
3132    begin
3133       if Debug_Generated_Code and then C /= ' ' then
3134          Set_Debug_Sloc;
3135       end if;
3136
3137       Write_Char (C);
3138    end Write_Char_Sloc;
3139
3140    --------------------------------
3141    -- Write_Condition_And_Reason --
3142    --------------------------------
3143
3144    procedure Write_Condition_And_Reason (Node : Node_Id) is
3145       Cond  : constant Node_Id := Condition (Node);
3146       Image : constant String  := RT_Exception_Code'Image
3147                                     (RT_Exception_Code'Val
3148                                        (UI_To_Int (Reason (Node))));
3149
3150    begin
3151       if Present (Cond) then
3152
3153          --  If condition is a single entity, or NOT with a single entity,
3154          --  output all on one line, since it will likely fit just fine.
3155
3156          if Is_Entity_Name (Cond)
3157            or else (Nkind (Cond) = N_Op_Not
3158                      and then Is_Entity_Name (Right_Opnd (Cond)))
3159          then
3160             Write_Str_With_Col_Check (" when ");
3161             Sprint_Node (Cond);
3162             Write_Char (' ');
3163
3164             --  Otherwise for more complex condition, multiple lines
3165
3166          else
3167             Write_Str_With_Col_Check (" when");
3168             Indent := Indent + 2;
3169             Write_Indent;
3170             Sprint_Node (Cond);
3171             Write_Indent;
3172             Indent := Indent - 2;
3173          end if;
3174
3175       --  If no condition, just need a space (all on one line)
3176
3177       else
3178          Write_Char (' ');
3179       end if;
3180
3181       --  Write the reason
3182
3183       Write_Char ('"');
3184
3185       for J in 4 .. Image'Last loop
3186          if Image (J) = '_' then
3187             Write_Char (' ');
3188          else
3189             Write_Char (Fold_Lower (Image (J)));
3190          end if;
3191       end loop;
3192
3193       Write_Str ("""]");
3194    end Write_Condition_And_Reason;
3195
3196    --------------------------------
3197    -- Write_Corresponding_Source --
3198    --------------------------------
3199
3200    procedure Write_Corresponding_Source (S : String) is
3201       Loc : Source_Ptr;
3202       Src : Source_Buffer_Ptr;
3203
3204    begin
3205       --  Ignore if not in dump source text mode, or if in freeze actions
3206
3207       if Dump_Source_Text and then Freeze_Indent = 0 then
3208
3209          --  Ignore null string
3210
3211          if S = "" then
3212             return;
3213          end if;
3214
3215          --  Ignore space or semicolon at end of given string
3216
3217          if S (S'Last) = ' ' or else S (S'Last) = ';' then
3218             Write_Corresponding_Source (S (S'First .. S'Last - 1));
3219             return;
3220          end if;
3221
3222          --  Loop to look at next lines not yet printed in source file
3223
3224          for L in
3225            Last_Line_Printed + 1 .. Last_Source_Line (Current_Source_File)
3226          loop
3227             Src := Source_Text (Current_Source_File);
3228             Loc := Line_Start (L, Current_Source_File);
3229
3230             --  If comment, keep looking
3231
3232             if Src (Loc .. Loc + 1) = "--" then
3233                null;
3234
3235             --  Search to first non-blank
3236
3237             else
3238                while Src (Loc) not in Line_Terminator loop
3239
3240                   --  Non-blank found
3241
3242                   if Src (Loc) /= ' ' and then Src (Loc) /= ASCII.HT then
3243
3244                      --  Loop through characters in string to see if we match
3245
3246                      for J in S'Range loop
3247
3248                         --  If mismatch, then not the case we are looking for
3249
3250                         if Src (Loc) /= S (J) then
3251                            return;
3252                         end if;
3253
3254                         Loc := Loc + 1;
3255                      end loop;
3256
3257                      --  If we fall through, string matched, if white space or
3258                      --  semicolon after the matched string, this is the case
3259                      --  we are looking for.
3260
3261                      if Src (Loc) in Line_Terminator
3262                        or else Src (Loc) = ' '
3263                        or else Src (Loc) = ASCII.HT
3264                        or else Src (Loc) = ';'
3265                      then
3266                         --  So output source lines up to and including this one
3267
3268                         Write_Source_Lines (L);
3269                         return;
3270                      end if;
3271                   end if;
3272
3273                   Loc := Loc + 1;
3274                end loop;
3275             end if;
3276
3277          --  Line was all blanks, or a comment line, keep looking
3278
3279          end loop;
3280       end if;
3281    end Write_Corresponding_Source;
3282
3283    -----------------------
3284    -- Write_Discr_Specs --
3285    -----------------------
3286
3287    procedure Write_Discr_Specs (N : Node_Id) is
3288       Specs : List_Id;
3289       Spec  : Node_Id;
3290
3291    begin
3292       Specs := Discriminant_Specifications (N);
3293
3294       if Present (Specs) then
3295          Write_Str_With_Col_Check (" (");
3296          Spec := First (Specs);
3297
3298          loop
3299             Sprint_Node (Spec);
3300             Next (Spec);
3301             exit when Spec = Empty;
3302
3303             --  Add semicolon, unless we are printing original tree and the
3304             --  next specification is part of a list (but not the first
3305             --  element of that list)
3306
3307             if not Dump_Original_Only or else not Prev_Ids (Spec) then
3308                Write_Str ("; ");
3309             end if;
3310          end loop;
3311
3312          Write_Char (')');
3313       end if;
3314    end Write_Discr_Specs;
3315
3316    -----------------
3317    -- Write_Ekind --
3318    -----------------
3319
3320    procedure Write_Ekind (E : Entity_Id) is
3321       S : constant String := Entity_Kind'Image (Ekind (E));
3322
3323    begin
3324       Name_Len := S'Length;
3325       Name_Buffer (1 .. Name_Len) := S;
3326       Set_Casing (Mixed_Case);
3327       Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3328    end Write_Ekind;
3329
3330    --------------
3331    -- Write_Id --
3332    --------------
3333
3334    procedure Write_Id (N : Node_Id) is
3335    begin
3336       --  Deal with outputting Itype
3337
3338       --  Note: if we are printing the full tree with -gnatds, then we may
3339       --  end up picking up the Associated_Node link from a generic template
3340       --  here which overlaps the Entity field, but as documented, Write_Itype
3341       --  is defended against junk calls.
3342
3343       if Nkind (N) in N_Entity then
3344          Write_Itype (N);
3345       elsif Nkind (N) in N_Has_Entity then
3346          Write_Itype (Entity (N));
3347       end if;
3348
3349       --  Case of a defining identifier
3350
3351       if Nkind (N) = N_Defining_Identifier then
3352
3353          --  If defining identifier has an interface name (and no
3354          --  address clause), then we output the interface name.
3355
3356          if (Is_Imported (N) or else Is_Exported (N))
3357            and then Present (Interface_Name (N))
3358            and then No (Address_Clause (N))
3359          then
3360             String_To_Name_Buffer (Strval (Interface_Name (N)));
3361             Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3362
3363          --  If no interface name (or inactive because there was
3364          --  an address clause), then just output the Chars name.
3365
3366          else
3367             Write_Name_With_Col_Check (Chars (N));
3368          end if;
3369
3370       --  Case of selector of an expanded name where the expanded name
3371       --  has an associated entity, output this entity.
3372
3373       elsif Nkind (Parent (N)) = N_Expanded_Name
3374         and then Selector_Name (Parent (N)) = N
3375         and then Present (Entity (Parent (N)))
3376       then
3377          Write_Id (Entity (Parent (N)));
3378
3379       --  For any other node with an associated entity, output it
3380
3381       elsif Nkind (N) in N_Has_Entity
3382         and then Present (Entity_Or_Associated_Node (N))
3383         and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
3384       then
3385          Write_Id (Entity (N));
3386
3387       --  All other cases, we just print the Chars field
3388
3389       else
3390          Write_Name_With_Col_Check (Chars (N));
3391       end if;
3392    end Write_Id;
3393
3394    -----------------------
3395    -- Write_Identifiers --
3396    -----------------------
3397
3398    function Write_Identifiers (Node : Node_Id) return Boolean is
3399    begin
3400       Sprint_Node (Defining_Identifier (Node));
3401       Update_Itype (Defining_Identifier (Node));
3402
3403       --  The remainder of the declaration must be printed unless we are
3404       --  printing the original tree and this is not the last identifier
3405
3406       return
3407          not Dump_Original_Only or else not More_Ids (Node);
3408
3409    end Write_Identifiers;
3410
3411    ------------------------
3412    -- Write_Implicit_Def --
3413    ------------------------
3414
3415    procedure Write_Implicit_Def (E : Entity_Id) is
3416       Ind : Node_Id;
3417
3418    begin
3419       case Ekind (E) is
3420          when E_Array_Subtype =>
3421             Write_Str_With_Col_Check ("subtype ");
3422             Write_Id (E);
3423             Write_Str_With_Col_Check (" is ");
3424             Write_Id (Base_Type (E));
3425             Write_Str_With_Col_Check (" (");
3426
3427             Ind := First_Index (E);
3428             while Present (Ind) loop
3429                Sprint_Node (Ind);
3430                Next_Index (Ind);
3431
3432                if Present (Ind) then
3433                   Write_Str (", ");
3434                end if;
3435             end loop;
3436
3437             Write_Str (");");
3438
3439          when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
3440             Write_Str_With_Col_Check ("subtype ");
3441             Write_Id (E);
3442             Write_Str (" is ");
3443             Write_Id (Etype (E));
3444             Write_Str_With_Col_Check (" range ");
3445             Sprint_Node (Scalar_Range (E));
3446             Write_Str (";");
3447
3448          when others =>
3449             Write_Str_With_Col_Check ("type ");
3450             Write_Id (E);
3451             Write_Str_With_Col_Check (" is <");
3452             Write_Ekind (E);
3453             Write_Str (">;");
3454       end case;
3455
3456    end Write_Implicit_Def;
3457
3458    ------------------
3459    -- Write_Indent --
3460    ------------------
3461
3462    procedure Write_Indent is
3463       Loc : constant Source_Ptr := Sloc (Dump_Node);
3464
3465    begin
3466       if Indent_Annull_Flag then
3467          Indent_Annull_Flag := False;
3468       else
3469          --  Deal with Dump_Source_Text output. Note that we ignore implicit
3470          --  label declarations, since they typically have the sloc of the
3471          --  corresponding label, which really messes up the -gnatL output.
3472
3473          if Dump_Source_Text
3474            and then Loc > No_Location
3475            and then Nkind (Dump_Node) /= N_Implicit_Label_Declaration
3476          then
3477             if Get_Source_File_Index (Loc) = Current_Source_File then
3478                Write_Source_Lines
3479                  (Get_Physical_Line_Number (Sloc (Dump_Node)));
3480             end if;
3481          end if;
3482
3483          Write_Eol;
3484
3485          for J in 1 .. Indent loop
3486             Write_Char (' ');
3487          end loop;
3488       end if;
3489    end Write_Indent;
3490
3491    ------------------------------
3492    -- Write_Indent_Identifiers --
3493    ------------------------------
3494
3495    function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3496    begin
3497       --  We need to start a new line for every node, except in the case
3498       --  where we are printing the original tree and this is not the first
3499       --  defining identifier in the list.
3500
3501       if not Dump_Original_Only or else not Prev_Ids (Node) then
3502          Write_Indent;
3503
3504       --  If printing original tree and this is not the first defining
3505       --  identifier in the list, then the previous call to this procedure
3506       --  printed only the name, and we add a comma to separate the names.
3507
3508       else
3509          Write_Str (", ");
3510       end if;
3511
3512       Sprint_Node (Defining_Identifier (Node));
3513
3514       --  The remainder of the declaration must be printed unless we are
3515       --  printing the original tree and this is not the last identifier
3516
3517       return
3518          not Dump_Original_Only or else not More_Ids (Node);
3519    end Write_Indent_Identifiers;
3520
3521    -----------------------------------
3522    -- Write_Indent_Identifiers_Sloc --
3523    -----------------------------------
3524
3525    function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3526    begin
3527       --  We need to start a new line for every node, except in the case
3528       --  where we are printing the original tree and this is not the first
3529       --  defining identifier in the list.
3530
3531       if not Dump_Original_Only or else not Prev_Ids (Node) then
3532          Write_Indent;
3533
3534       --  If printing original tree and this is not the first defining
3535       --  identifier in the list, then the previous call to this procedure
3536       --  printed only the name, and we add a comma to separate the names.
3537
3538       else
3539          Write_Str (", ");
3540       end if;
3541
3542       Set_Debug_Sloc;
3543       Sprint_Node (Defining_Identifier (Node));
3544
3545       --  The remainder of the declaration must be printed unless we are
3546       --  printing the original tree and this is not the last identifier
3547
3548       return not Dump_Original_Only or else not More_Ids (Node);
3549    end Write_Indent_Identifiers_Sloc;
3550
3551    ----------------------
3552    -- Write_Indent_Str --
3553    ----------------------
3554
3555    procedure Write_Indent_Str (S : String) is
3556    begin
3557       Write_Corresponding_Source (S);
3558       Write_Indent;
3559       Write_Str (S);
3560    end Write_Indent_Str;
3561
3562    ---------------------------
3563    -- Write_Indent_Str_Sloc --
3564    ---------------------------
3565
3566    procedure Write_Indent_Str_Sloc (S : String) is
3567    begin
3568       Write_Corresponding_Source (S);
3569       Write_Indent;
3570       Write_Str_Sloc (S);
3571    end Write_Indent_Str_Sloc;
3572
3573    -----------------
3574    -- Write_Itype --
3575    -----------------
3576
3577    procedure Write_Itype (Typ : Entity_Id) is
3578
3579       procedure Write_Header (T : Boolean := True);
3580       --  Write type if T is True, subtype if T is false
3581
3582       ------------------
3583       -- Write_Header --
3584       ------------------
3585
3586       procedure Write_Header (T : Boolean := True) is
3587       begin
3588          if T then
3589             Write_Str ("[type ");
3590          else
3591             Write_Str ("[subtype ");
3592          end if;
3593
3594          Write_Name_With_Col_Check (Chars (Typ));
3595          Write_Str (" is ");
3596       end Write_Header;
3597
3598    --  Start of processing for Write_Itype
3599
3600    begin
3601       if Nkind (Typ) in N_Entity
3602         and then Is_Itype (Typ)
3603         and then not Itype_Printed (Typ)
3604       then
3605          --  Itype to be printed
3606
3607          declare
3608             B : constant Node_Id := Etype (Typ);
3609             X : Node_Id;
3610             P : constant Node_Id := Parent (Typ);
3611
3612             S : constant Saved_Output_Buffer := Save_Output_Buffer;
3613             --  Save current output buffer
3614
3615             Old_Sloc : Source_Ptr;
3616             --  Save sloc of related node, so it is not modified when
3617             --  printing with -gnatD.
3618
3619          begin
3620             --  Write indentation at start of line
3621
3622             for J in 1 .. Indent loop
3623                Write_Char (' ');
3624             end loop;
3625
3626             --  If we have a constructed declaration, print it
3627
3628             if Present (P) and then Nkind (P) in N_Declaration then
3629
3630                --  We must set Itype_Printed true before the recursive call to
3631                --  print the node, otherwise we get an infinite recursion!
3632
3633                Set_Itype_Printed (Typ, True);
3634
3635                --  Write the declaration enclosed in [], avoiding new line
3636                --  at start of declaration, and semicolon at end.
3637
3638                --  Note: The itype may be imported from another unit, in which
3639                --  case we do not want to modify the Sloc of the declaration.
3640                --  Otherwise the itype may appear to be in the current unit,
3641                --  and the back-end will reject a reference out of scope.
3642
3643                Write_Char ('[');
3644                Indent_Annull_Flag := True;
3645                Old_Sloc := Sloc (P);
3646                Sprint_Node (P);
3647                Set_Sloc (P, Old_Sloc);
3648                Write_Erase_Char (';');
3649
3650             --  If no constructed declaration, then we have to concoct the
3651             --  source corresponding to the type entity that we have at hand.
3652
3653             else
3654                case Ekind (Typ) is
3655
3656                   --  Access types and subtypes
3657
3658                   when Access_Kind =>
3659                      Write_Header (Ekind (Typ) = E_Access_Type);
3660                      Write_Str ("access ");
3661
3662                      if Is_Access_Constant (Typ) then
3663                         Write_Str ("constant ");
3664                      elsif Can_Never_Be_Null (Typ) then
3665                         Write_Str ("not null ");
3666                      end if;
3667
3668                      Write_Id (Directly_Designated_Type (Typ));
3669
3670                      --  Array types and string types
3671
3672                   when E_Array_Type | E_String_Type =>
3673                      Write_Header;
3674                      Write_Str ("array (");
3675
3676                      X := First_Index (Typ);
3677                      loop
3678                         Sprint_Node (X);
3679
3680                         if not Is_Constrained (Typ) then
3681                            Write_Str (" range <>");
3682                         end if;
3683
3684                         Next_Index (X);
3685                         exit when No (X);
3686                         Write_Str (", ");
3687                      end loop;
3688
3689                      Write_Str (") of ");
3690                      Sprint_Node (Component_Type (Typ));
3691
3692                      --  Array subtypes and string subtypes
3693
3694                   when E_Array_Subtype | E_String_Subtype =>
3695                      Write_Header (False);
3696                      Write_Id (Etype (Typ));
3697                      Write_Str (" (");
3698
3699                      X := First_Index (Typ);
3700                      loop
3701                         Sprint_Node (X);
3702                         Next_Index (X);
3703                         exit when No (X);
3704                         Write_Str (", ");
3705                      end loop;
3706
3707                      Write_Char (')');
3708
3709                      --  Signed integer types, and modular integer subtypes
3710
3711                   when E_Signed_Integer_Type     |
3712                        E_Signed_Integer_Subtype  |
3713                        E_Modular_Integer_Subtype =>
3714
3715                      Write_Header (Ekind (Typ) = E_Signed_Integer_Type);
3716
3717                      if Ekind (Typ) = E_Signed_Integer_Type then
3718                         Write_Str ("new ");
3719                      end if;
3720
3721                      Write_Id (B);
3722
3723                      --  Print bounds if different from base type
3724
3725                      declare
3726                         L  : constant Node_Id := Type_Low_Bound (Typ);
3727                         H  : constant Node_Id := Type_High_Bound (Typ);
3728                         LE : Node_Id;
3729                         HE : Node_Id;
3730
3731                      begin
3732                         --  B can either be a scalar type, in which case the
3733                         --  declaration of Typ may constrain it with different
3734                         --  bounds, or a private type, in which case we know
3735                         --  that the declaration of Typ cannot have a scalar
3736                         --  constraint.
3737
3738                         if Is_Scalar_Type (B) then
3739                            LE := Type_Low_Bound (B);
3740                            HE := Type_High_Bound (B);
3741                         else
3742                            LE := Empty;
3743                            HE := Empty;
3744                         end if;
3745
3746                         if No (LE)
3747                           or else (True
3748                             and then Nkind (L) = N_Integer_Literal
3749                             and then Nkind (H) = N_Integer_Literal
3750                             and then Nkind (LE) = N_Integer_Literal
3751                             and then Nkind (HE) = N_Integer_Literal
3752                             and then UI_Eq (Intval (L), Intval (LE))
3753                             and then UI_Eq (Intval (H), Intval (HE)))
3754                         then
3755                            null;
3756
3757                         else
3758                            Write_Str (" range ");
3759                            Sprint_Node (Type_Low_Bound (Typ));
3760                            Write_Str (" .. ");
3761                            Sprint_Node (Type_High_Bound (Typ));
3762                         end if;
3763                      end;
3764
3765                      --  Modular integer types
3766
3767                   when E_Modular_Integer_Type =>
3768                      Write_Header;
3769                      Write_Str (" mod ");
3770                      Write_Uint_With_Col_Check (Modulus (Typ), Auto);
3771
3772                      --  Floating point types and subtypes
3773
3774                   when E_Floating_Point_Type    |
3775                        E_Floating_Point_Subtype =>
3776
3777                      Write_Header (Ekind (Typ) = E_Floating_Point_Type);
3778
3779                      if Ekind (Typ) = E_Floating_Point_Type then
3780                         Write_Str ("new ");
3781                      end if;
3782
3783                      Write_Id (Etype (Typ));
3784
3785                      if Digits_Value (Typ) /= Digits_Value (Etype (Typ)) then
3786                         Write_Str (" digits ");
3787                         Write_Uint_With_Col_Check
3788                           (Digits_Value (Typ), Decimal);
3789                      end if;
3790
3791                      --  Print bounds if not different from base type
3792
3793                      declare
3794                         L  : constant Node_Id := Type_Low_Bound (Typ);
3795                         H  : constant Node_Id := Type_High_Bound (Typ);
3796                         LE : constant Node_Id := Type_Low_Bound (B);
3797                         HE : constant Node_Id := Type_High_Bound (B);
3798
3799                      begin
3800                         if Nkind (L) = N_Real_Literal
3801                           and then Nkind (H) = N_Real_Literal
3802                           and then Nkind (LE) = N_Real_Literal
3803                           and then Nkind (HE) = N_Real_Literal
3804                           and then UR_Eq (Realval (L), Realval (LE))
3805                           and then UR_Eq (Realval (H), Realval (HE))
3806                         then
3807                            null;
3808
3809                         else
3810                            Write_Str (" range ");
3811                            Sprint_Node (Type_Low_Bound (Typ));
3812                            Write_Str (" .. ");
3813                            Sprint_Node (Type_High_Bound (Typ));
3814                         end if;
3815                      end;
3816
3817                   --  Record subtypes
3818
3819                   when E_Record_Subtype =>
3820                      Write_Header (False);
3821                      Write_Str ("record");
3822                      Indent_Begin;
3823
3824                      declare
3825                         C : Entity_Id;
3826                      begin
3827                         C := First_Entity (Typ);
3828                         while Present (C) loop
3829                            Write_Indent;
3830                            Write_Id (C);
3831                            Write_Str (" : ");
3832                            Write_Id (Etype (C));
3833                            Next_Entity (C);
3834                         end loop;
3835                      end;
3836
3837                      Indent_End;
3838                      Write_Indent_Str (" end record");
3839
3840                   --  Class-Wide types
3841
3842                   when E_Class_Wide_Type    |
3843                        E_Class_Wide_Subtype =>
3844                      Write_Header;
3845                      Write_Name_With_Col_Check (Chars (Etype (Typ)));
3846                      Write_Str ("'Class");
3847
3848                   --  Subprogram types
3849
3850                   when E_Subprogram_Type =>
3851                      Write_Header;
3852
3853                      if Etype (Typ) = Standard_Void_Type then
3854                         Write_Str ("procedure");
3855                      else
3856                         Write_Str ("function");
3857                      end if;
3858
3859                      if Present (First_Entity (Typ)) then
3860                         Write_Str (" (");
3861
3862                         declare
3863                            Param : Entity_Id;
3864
3865                         begin
3866                            Param := First_Entity (Typ);
3867                            loop
3868                               Write_Id (Param);
3869                               Write_Str (" : ");
3870
3871                               if Ekind (Param) = E_In_Out_Parameter then
3872                                  Write_Str ("in out ");
3873                               elsif Ekind (Param) = E_Out_Parameter then
3874                                  Write_Str ("out ");
3875                               end if;
3876
3877                               Write_Id (Etype (Param));
3878                               Next_Entity (Param);
3879                               exit when No (Param);
3880                               Write_Str (", ");
3881                            end loop;
3882
3883                            Write_Char (')');
3884                         end;
3885                      end if;
3886
3887                      if Etype (Typ) /= Standard_Void_Type then
3888                         Write_Str (" return ");
3889                         Write_Id (Etype (Typ));
3890                      end if;
3891
3892                   when E_String_Literal_Subtype =>
3893                      declare
3894                         LB  : constant Uint :=
3895                                 Intval (String_Literal_Low_Bound (Typ));
3896                         Len : constant Uint :=
3897                                 String_Literal_Length (Typ);
3898                      begin
3899                         Write_Str ("String (");
3900                         Write_Int (UI_To_Int (LB));
3901                         Write_Str (" .. ");
3902                         Write_Int (UI_To_Int (LB + Len) - 1);
3903                         Write_Str (");");
3904                      end;
3905
3906                   --  For all other Itypes, print ??? (fill in later)
3907
3908                   when others =>
3909                      Write_Header (True);
3910                      Write_Str ("???");
3911
3912                end case;
3913             end if;
3914
3915             --  Add terminating bracket and restore output buffer
3916
3917             Write_Char (']');
3918             Write_Eol;
3919             Restore_Output_Buffer (S);
3920          end;
3921
3922          Set_Itype_Printed (Typ);
3923       end if;
3924    end Write_Itype;
3925
3926    -------------------------------
3927    -- Write_Name_With_Col_Check --
3928    -------------------------------
3929
3930    procedure Write_Name_With_Col_Check (N : Name_Id) is
3931       J : Natural;
3932
3933    begin
3934       Get_Name_String (N);
3935
3936       --  Deal with -gnatI which replaces digits in an internal
3937       --  name by three dots (e.g. R7b becomes R...b).
3938
3939       if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
3940          J := 2;
3941          while J < Name_Len loop
3942             exit when Name_Buffer (J) not in 'A' .. 'Z';
3943             J := J + 1;
3944          end loop;
3945
3946          if Name_Buffer (J) in '0' .. '9' then
3947             Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
3948             Write_Str ("...");
3949
3950             while J <= Name_Len loop
3951                if Name_Buffer (J) not in '0' .. '9' then
3952                   Write_Str (Name_Buffer (J .. Name_Len));
3953                   exit;
3954
3955                else
3956                   J := J + 1;
3957                end if;
3958             end loop;
3959
3960             return;
3961          end if;
3962       end if;
3963
3964       --  Fall through for normal case
3965
3966       Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3967    end Write_Name_With_Col_Check;
3968
3969    ------------------------------------
3970    -- Write_Name_With_Col_Check_Sloc --
3971    ------------------------------------
3972
3973    procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3974    begin
3975       Get_Name_String (N);
3976       Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3977    end Write_Name_With_Col_Check_Sloc;
3978
3979    --------------------
3980    -- Write_Operator --
3981    --------------------
3982
3983    procedure Write_Operator (N : Node_Id; S : String) is
3984       F : Natural := S'First;
3985       T : Natural := S'Last;
3986
3987    begin
3988       --  If no overflow check, just write string out, and we are done
3989
3990       if not Do_Overflow_Check (N) then
3991          Write_Str_Sloc (S);
3992
3993       --  If overflow check, we want to surround the operator with curly
3994       --  brackets, but not include spaces within the brackets.
3995
3996       else
3997          if S (F) = ' ' then
3998             Write_Char (' ');
3999             F := F + 1;
4000          end if;
4001
4002          if S (T) = ' ' then
4003             T := T - 1;
4004          end if;
4005
4006          Write_Char ('{');
4007          Write_Str_Sloc (S (F .. T));
4008          Write_Char ('}');
4009
4010          if S (S'Last) = ' ' then
4011             Write_Char (' ');
4012          end if;
4013       end if;
4014    end Write_Operator;
4015
4016    -----------------------
4017    -- Write_Param_Specs --
4018    -----------------------
4019
4020    procedure Write_Param_Specs (N : Node_Id) is
4021       Specs  : List_Id;
4022       Spec   : Node_Id;
4023       Formal : Node_Id;
4024
4025    begin
4026       Specs := Parameter_Specifications (N);
4027
4028       if Is_Non_Empty_List (Specs) then
4029          Write_Str_With_Col_Check (" (");
4030          Spec := First (Specs);
4031
4032          loop
4033             Sprint_Node (Spec);
4034             Formal := Defining_Identifier (Spec);
4035             Next (Spec);
4036             exit when Spec = Empty;
4037
4038             --  Add semicolon, unless we are printing original tree and the
4039             --  next specification is part of a list (but not the first
4040             --  element of that list)
4041
4042             if not Dump_Original_Only or else not Prev_Ids (Spec) then
4043                Write_Str ("; ");
4044             end if;
4045          end loop;
4046
4047          --  Write out any extra formals
4048
4049          while Present (Extra_Formal (Formal)) loop
4050             Formal := Extra_Formal (Formal);
4051             Write_Str ("; ");
4052             Write_Name_With_Col_Check (Chars (Formal));
4053             Write_Str (" : ");
4054             Write_Name_With_Col_Check (Chars (Etype (Formal)));
4055          end loop;
4056
4057          Write_Char (')');
4058       end if;
4059    end Write_Param_Specs;
4060
4061    -----------------------
4062    -- Write_Rewrite_Str --
4063    -----------------------
4064
4065    procedure Write_Rewrite_Str (S : String) is
4066    begin
4067       if not Dump_Generated_Only then
4068          if S'Length = 3 and then S = ">>>" then
4069             Write_Str (">>>");
4070          else
4071             Write_Str_With_Col_Check (S);
4072          end if;
4073       end if;
4074    end Write_Rewrite_Str;
4075
4076    -----------------------
4077    -- Write_Source_Line --
4078    -----------------------
4079
4080    procedure Write_Source_Line (L : Physical_Line_Number) is
4081       Loc : Source_Ptr;
4082       Src : Source_Buffer_Ptr;
4083       Scn : Source_Ptr;
4084
4085    begin
4086       if Dump_Source_Text then
4087          Src := Source_Text (Current_Source_File);
4088          Loc := Line_Start (L, Current_Source_File);
4089          Write_Eol;
4090
4091          --  See if line is a comment line, if not, and if not line one,
4092          --  precede with blank line.
4093
4094          Scn := Loc;
4095          while Src (Scn) = ' ' or else Src (Scn) = ASCII.HT loop
4096             Scn := Scn + 1;
4097          end loop;
4098
4099          if (Src (Scn) in Line_Terminator
4100               or else Src (Scn .. Scn + 1) /= "--")
4101            and then L /= 1
4102          then
4103             Write_Eol;
4104          end if;
4105
4106          --  Now write the source text of the line
4107
4108          Write_Str ("-- ");
4109          Write_Int (Int (L));
4110          Write_Str (": ");
4111
4112          while Src (Loc) not in Line_Terminator loop
4113             Write_Char (Src (Loc));
4114             Loc := Loc + 1;
4115          end loop;
4116       end if;
4117    end Write_Source_Line;
4118
4119    ------------------------
4120    -- Write_Source_Lines --
4121    ------------------------
4122
4123    procedure Write_Source_Lines (L : Physical_Line_Number) is
4124    begin
4125       while Last_Line_Printed < L loop
4126          Last_Line_Printed := Last_Line_Printed + 1;
4127          Write_Source_Line (Last_Line_Printed);
4128       end loop;
4129    end Write_Source_Lines;
4130
4131    --------------------
4132    -- Write_Str_Sloc --
4133    --------------------
4134
4135    procedure Write_Str_Sloc (S : String) is
4136    begin
4137       for J in S'Range loop
4138          Write_Char_Sloc (S (J));
4139       end loop;
4140    end Write_Str_Sloc;
4141
4142    ------------------------------
4143    -- Write_Str_With_Col_Check --
4144    ------------------------------
4145
4146    procedure Write_Str_With_Col_Check (S : String) is
4147    begin
4148       if Int (S'Last) + Column > Line_Limit then
4149          Write_Indent_Str ("  ");
4150
4151          if S (S'First) = ' ' then
4152             Write_Str (S (S'First + 1 .. S'Last));
4153          else
4154             Write_Str (S);
4155          end if;
4156
4157       else
4158          Write_Str (S);
4159       end if;
4160    end Write_Str_With_Col_Check;
4161
4162    -----------------------------------
4163    -- Write_Str_With_Col_Check_Sloc --
4164    -----------------------------------
4165
4166    procedure Write_Str_With_Col_Check_Sloc (S : String) is
4167    begin
4168       if Int (S'Last) + Column > Line_Limit then
4169          Write_Indent_Str ("  ");
4170
4171          if S (S'First) = ' ' then
4172             Write_Str_Sloc (S (S'First + 1 .. S'Last));
4173          else
4174             Write_Str_Sloc (S);
4175          end if;
4176
4177       else
4178          Write_Str_Sloc (S);
4179       end if;
4180    end Write_Str_With_Col_Check_Sloc;
4181
4182    -------------------------------
4183    -- Write_Uint_With_Col_Check --
4184    -------------------------------
4185
4186    procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format) is
4187    begin
4188       Col_Check (UI_Decimal_Digits_Hi (U));
4189       UI_Write (U, Format);
4190    end Write_Uint_With_Col_Check;
4191
4192    ------------------------------------
4193    -- Write_Uint_With_Col_Check_Sloc --
4194    ------------------------------------
4195
4196    procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
4197    begin
4198       Col_Check (UI_Decimal_Digits_Hi (U));
4199       Set_Debug_Sloc;
4200       UI_Write (U, Format);
4201    end Write_Uint_With_Col_Check_Sloc;
4202
4203    -------------------------------------
4204    -- Write_Ureal_With_Col_Check_Sloc --
4205    -------------------------------------
4206
4207    procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
4208       D : constant Uint := Denominator (U);
4209       N : constant Uint := Numerator (U);
4210
4211    begin
4212       Col_Check
4213         (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
4214       Set_Debug_Sloc;
4215       UR_Write (U);
4216    end Write_Ureal_With_Col_Check_Sloc;
4217
4218 end Sprint;