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