OSDN Git Service

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