41intnam.ads, [...]: Merge in ACT changes.
[platform/upstream/gcc.git] / gcc / ada / style.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                                S T Y L E                                 --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --                            $Revision$
10 --                                                                          --
11 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
12 --                                                                          --
13 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- GNAT was originally developed  by the GNAT team at  New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 --                                                                          --
27 ------------------------------------------------------------------------------
28
29 --  This version of the Style package implements the standard GNAT style
30 --  checking rules. For documentation of these rules, see comments on the
31 --  individual procedures.
32
33 with Atree;    use Atree;
34 with Casing;   use Casing;
35 with Csets;    use Csets;
36 with Einfo;    use Einfo;
37 with Errout;   use Errout;
38 with Namet;    use Namet;
39 with Opt;      use Opt;
40 with Scn;      use Scn;
41 with Scans;    use Scans;
42 with Sinfo;    use Sinfo;
43 with Sinput;   use Sinput;
44 with Stand;    use Stand;
45 with Stylesw;  use Stylesw;
46
47 package body Style is
48
49    -----------------------
50    -- Local Subprograms --
51    -----------------------
52
53    procedure Error_Space_Not_Allowed (S : Source_Ptr);
54    --  Posts an error message indicating that a space is not allowed
55    --  at the given source location.
56
57    procedure Error_Space_Required (S : Source_Ptr);
58    --  Posts an error message indicating that a space is required at
59    --  the given source location.
60
61    procedure Require_Following_Space;
62    pragma Inline (Require_Following_Space);
63    --  Require token to be followed by white space. Used only if in GNAT
64    --  style checking mode.
65
66    procedure Require_Preceding_Space;
67    pragma Inline (Require_Preceding_Space);
68    --  Require token to be preceded by white space. Used only if in GNAT
69    --  style checking mode.
70
71    -----------------------
72    -- Body_With_No_Spec --
73    -----------------------
74
75    --  If the check specs mode (-gnatys) is set, then all subprograms must
76    --  have specs unless they are parameterless procedures that are not child
77    --  units at the library level (i.e. they are possible main programs).
78
79    procedure Body_With_No_Spec (N : Node_Id) is
80    begin
81       if Style_Check_Specs then
82          if Nkind (Parent (N)) = N_Compilation_Unit then
83             declare
84                Spec  : constant Node_Id := Specification (N);
85                Defnm : constant Node_Id := Defining_Unit_Name (Spec);
86
87             begin
88                if Nkind (Spec) = N_Procedure_Specification
89                  and then Nkind (Defnm) = N_Defining_Identifier
90                  and then No (First_Formal (Defnm))
91                then
92                   return;
93                end if;
94             end;
95          end if;
96
97          Error_Msg_N ("(style): subprogram body has no previous spec", N);
98       end if;
99    end Body_With_No_Spec;
100
101    ----------------------
102    -- Check_Abs_Or_Not --
103    ----------------------
104
105    --  In check tokens mode (-gnatyt), ABS/NOT must be followed by a space
106
107    procedure Check_Abs_Not is
108    begin
109       if Style_Check_Tokens then
110          if Source (Scan_Ptr) > ' ' then
111             Error_Space_Required (Scan_Ptr);
112          end if;
113       end if;
114    end Check_Abs_Not;
115
116    -----------------
117    -- Check_Arrow --
118    -----------------
119
120    --  In check tokens mode (-gnatys), arrow must be surrounded by spaces
121
122    procedure Check_Arrow is
123    begin
124       if Style_Check_Tokens then
125          Require_Preceding_Space;
126          Require_Following_Space;
127       end if;
128    end Check_Arrow;
129
130    --------------------------
131    -- Check_Attribute_Name --
132    --------------------------
133
134    --  In check attribute casing mode (-gnatya), attribute names must be
135    --  mixed case, i.e. start with an upper case letter, and otherwise
136    --  lower case, except after an underline character.
137
138    procedure Check_Attribute_Name (Reserved : Boolean) is
139       pragma Warnings (Off, Reserved);
140
141    begin
142       if Style_Check_Attribute_Casing then
143          if Determine_Token_Casing /= Mixed_Case then
144             Error_Msg_SC ("(style) bad capitalization, mixed case required");
145          end if;
146       end if;
147    end Check_Attribute_Name;
148
149    ---------------------------
150    -- Check_Binary_Operator --
151    ---------------------------
152
153    --  In check token mode (-gnatyt), binary operators other than the special
154    --  case of exponentiation require surrounding space characters.
155
156    procedure Check_Binary_Operator is
157    begin
158       if Style_Check_Tokens then
159          Require_Preceding_Space;
160          Require_Following_Space;
161       end if;
162    end Check_Binary_Operator;
163
164    ---------------
165    -- Check_Box --
166    ---------------
167
168    --  In check token mode (-gnatyt), box must be preceded by a space or by
169    --  a left parenthesis. Spacing checking on the surrounding tokens takes
170    --  care of the remaining checks.
171
172    procedure Check_Box is
173    begin
174       if Style_Check_Tokens then
175          if Prev_Token /= Tok_Left_Paren then
176             Require_Preceding_Space;
177          end if;
178       end if;
179    end Check_Box;
180
181    -----------------
182    -- Check_Colon --
183    -----------------
184
185    --  In check token mode (-gnatyt), colon must be surrounded by spaces
186
187    procedure Check_Colon is
188    begin
189       if Style_Check_Tokens then
190          Require_Preceding_Space;
191          Require_Following_Space;
192       end if;
193    end Check_Colon;
194
195    -----------------------
196    -- Check_Colon_Equal --
197    -----------------------
198
199    --  In check token mode (-gnatyt), := must be surrounded by spaces
200
201    procedure Check_Colon_Equal is
202    begin
203       if Style_Check_Tokens then
204          Require_Preceding_Space;
205          Require_Following_Space;
206       end if;
207    end Check_Colon_Equal;
208
209    -----------------
210    -- Check_Comma --
211    -----------------
212
213    --  In check token mode (-gnatyt), comma must be either the first
214    --  token on a line, or be preceded by a non-blank character.
215    --  It must also always be followed by a blank.
216
217    procedure Check_Comma is
218    begin
219       if Style_Check_Tokens then
220          if Token_Ptr > First_Non_Blank_Location
221            and then Source (Token_Ptr - 1) = ' '
222          then
223             Error_Space_Not_Allowed (Token_Ptr - 1);
224          end if;
225
226          if Source (Scan_Ptr) > ' ' then
227             Error_Space_Required (Scan_Ptr);
228          end if;
229       end if;
230    end Check_Comma;
231
232    -------------------
233    -- Check_Comment --
234    -------------------
235
236    --  In check comment mode (-gnatyc) there are several requirements on the
237    --  format of comments. The following are permissible comment formats:
238
239    --    1. Any comment that is not at the start of a line, i.e. where the
240    --       initial minuses are not the first non-blank characters on the
241    --       line must have at least one blank after the second minus.
242
243    --    2. A row of all minuses of any length is permitted (see procedure
244    --       box above in the source of this routine).
245
246    --    3. A comment line starting with two minuses and a space, and ending
247    --       with a space and two minuses. Again see the procedure title box
248    --       immediately above in the source.
249
250    --    4. A full line comment where two spaces follow the two minus signs.
251    --       This is the normal comment format in GNAT style, as typified by
252    --       the comments you are reading now.
253
254    --    5. A full line comment where the first character after the second
255    --       minus is a special character, i.e. a character in the ASCII
256    --       range 16#21#..16#2F# or 16#3A#..16#3F#. This allows special
257    --       comments, such as those generated by gnatprep, or those that
258    --       appear in the SPARK annotation language to be accepted.
259
260    procedure Check_Comment is
261       S : Source_Ptr;
262       C : Character;
263
264    begin
265       --  Can never have a non-blank character preceding the first minus
266
267       if Style_Check_Comments then
268          if Scan_Ptr > Source_First (Current_Source_File)
269            and then Source (Scan_Ptr - 1) > ' '
270          then
271             Error_Msg_S ("(style) space required");
272          end if;
273       end if;
274
275       --  For a comment that is not at the start of the line, the only
276       --  requirement is that we cannot have a non-blank character after
277       --  the second minus sign.
278
279       if Scan_Ptr /= First_Non_Blank_Location then
280          if Style_Check_Comments then
281             if Source (Scan_Ptr + 2) > ' ' then
282                Error_Msg ("(style) space required", Scan_Ptr + 2);
283             end if;
284          end if;
285
286          return;
287
288       --  Case of a comment that is at the start of a line
289
290       else
291          --  First check, must be in appropriately indented column
292
293          if Style_Check_Indentation /= 0 then
294             if Start_Column rem Style_Check_Indentation /= 0 then
295                Error_Msg_S ("(style) bad column");
296                return;
297             end if;
298          end if;
299
300          --  Now check form of the comment
301
302          if not Style_Check_Comments then
303             return;
304
305          --  Case of not followed by a blank. Usually wrong, but there are
306          --  some exceptions that we permit.
307
308          elsif Source (Scan_Ptr + 2) /= ' ' then
309             C := Source (Scan_Ptr + 2);
310
311             --  Case of -- all on its own on a line is OK
312
313             if C < ' ' then
314                return;
315
316             --  Case of --x, x special character is OK (gnatprep/SPARK/etc.)
317
318             elsif Character'Pos (C) in 16#21# .. 16#2F#
319                     or else
320                   Character'Pos (C) in 16#3A# .. 16#3F#
321             then
322                return;
323
324             --  Otherwise only cases allowed are when the entire line is
325             --  made up of minus signs (case of a box comment).
326
327             else
328                S := Scan_Ptr + 2;
329
330                while Source (S) >= ' ' loop
331                   if Source (S) /= '-' then
332                      Error_Space_Required (Scan_Ptr + 2);
333                      return;
334                   end if;
335
336                   S := S + 1;
337                end loop;
338             end if;
339
340          --  If we are followed by a blank, then the comment is OK if the
341          --  character following this blank is another blank or a format
342          --  effector.
343
344          elsif Source (Scan_Ptr + 3) <= ' ' then
345             return;
346
347          --  Here is the case where we only have one blank after the two minus
348          --  signs, which is an error unless the line ends with two blanks, the
349          --  case of a box comment.
350
351          else
352             S := Scan_Ptr + 3;
353
354             while Source (S) not in Line_Terminator loop
355                S := S + 1;
356             end loop;
357
358             if Source (S - 1) /= '-' or else Source (S - 2) /= '-' then
359                Error_Space_Required (Scan_Ptr + 3);
360             end if;
361          end if;
362       end if;
363    end Check_Comment;
364
365    -------------------
366    -- Check_Dot_Dot --
367    -------------------
368
369    --  In check token mode (-gnatyt), colon must be surrounded by spaces
370
371    procedure Check_Dot_Dot is
372    begin
373       if Style_Check_Tokens then
374          Require_Preceding_Space;
375          Require_Following_Space;
376       end if;
377    end Check_Dot_Dot;
378
379    -----------------------------------
380    -- Check_Exponentiation_Operator --
381    -----------------------------------
382
383    --  No spaces are required for the ** operator in GNAT style check mode
384
385    procedure Check_Exponentiation_Operator is
386    begin
387       null;
388    end Check_Exponentiation_Operator;
389
390    --------------
391    -- Check_HT --
392    --------------
393
394    --  In check horizontal tab mode (-gnatyh), tab characters are not allowed
395
396    procedure Check_HT is
397    begin
398       if Style_Check_Horizontal_Tabs then
399          Error_Msg_S ("(style) horizontal tab not allowed");
400       end if;
401    end Check_HT;
402
403    ----------------------
404    -- Check_Identifier --
405    ----------------------
406
407    --  In check references mode (-gnatyr), identifier uses must be cased
408    --  the same way as the corresponding identifier declaration.
409
410    procedure Check_Identifier
411      (Ref : Node_Or_Entity_Id;
412       Def : Node_Or_Entity_Id)
413    is
414       Sref : Source_Ptr := Sloc (Ref);
415       Sdef : Source_Ptr := Sloc (Def);
416       Tref : Source_Buffer_Ptr;
417       Tdef : Source_Buffer_Ptr;
418       Nlen : Nat;
419       Cas  : Casing_Type;
420
421    begin
422       --  If reference does not come from source, nothing to check
423
424       if not Comes_From_Source (Ref) then
425          return;
426
427       --  Case of definition comes from source
428
429       elsif Comes_From_Source (Def) then
430
431          --  Check same casing if we are checking references
432
433          if Style_Check_References then
434             Tref := Source_Text (Get_Source_File_Index (Sref));
435             Tdef := Source_Text (Get_Source_File_Index (Sdef));
436
437             --  Ignore operator name case completely. This also catches the
438             --  case of where one is an operator and the other is not. This
439             --  is a phenomenon from rewriting of operators as functions,
440             --  and is to be ignored.
441
442             if Tref (Sref) = '"' or else Tdef (Sdef) = '"' then
443                return;
444
445             else
446                while Tref (Sref) = Tdef (Sdef) loop
447
448                   --  If end of identifier, all done
449
450                   if not Identifier_Char (Tref (Sref)) then
451                      return;
452
453                   --  Otherwise loop continues
454
455                   else
456                      Sref := Sref + 1;
457                      Sdef := Sdef + 1;
458                   end if;
459                end loop;
460
461                --  Fall through loop when mismatch between identifiers
462                --  If either identifier is not terminated, error.
463
464                if Identifier_Char (Tref (Sref))
465                     or else
466                   Identifier_Char (Tdef (Sdef))
467                then
468                   Error_Msg_Node_1 := Def;
469                   Error_Msg_Sloc := Sloc (Def);
470                   Error_Msg
471                     ("(style) bad casing of & declared#", Sref);
472                   return;
473
474                --  Else end of identifiers, and they match
475
476                else
477                   return;
478                end if;
479             end if;
480          end if;
481
482       --  Case of definition in package Standard
483
484       elsif Sdef = Standard_Location then
485
486          --  Check case of identifiers in Standard
487
488          if Style_Check_Standard then
489             Tref := Source_Text (Get_Source_File_Index (Sref));
490
491             --  Ignore operators
492
493             if Tref (Sref) = '"' then
494                null;
495
496             --  Special case of ASCII
497
498             else
499                if Entity (Ref) = Standard_ASCII then
500                   Cas := All_Upper_Case;
501
502                elsif Entity (Ref) in SE (S_LC_A) .. SE (S_LC_Z)
503                        or else
504                      Entity (Ref) in SE (S_NUL) .. SE (S_US)
505                        or else
506                      Entity (Ref) = SE (S_DEL)
507                then
508                   Cas := All_Upper_Case;
509
510                else
511                   Cas := Mixed_Case;
512                end if;
513
514                Nlen  := Length_Of_Name (Chars (Ref));
515
516                if Determine_Casing
517                     (Tref (Sref .. Sref + Source_Ptr (Nlen) - 1)) = Cas
518                then
519                   null;
520                else
521                   Error_Msg_N
522                     ("(style) bad casing for entity in Standard", Ref);
523                end if;
524             end if;
525          end if;
526       end if;
527    end Check_Identifier;
528
529    -----------------------
530    -- Check_Indentation --
531    -----------------------
532
533    --  In check indentation mode (-gnatyn for n a digit), a new statement or
534    --  declaration is required to start in a column that is a multiple of the
535    --  indentiation amount.
536
537    procedure Check_Indentation is
538    begin
539       if Style_Check_Indentation /= 0 then
540          if Token_Ptr = First_Non_Blank_Location
541            and then Start_Column rem Style_Check_Indentation /= 0
542          then
543             Error_Msg_SC ("(style) bad indentation");
544          end if;
545       end if;
546    end Check_Indentation;
547
548    ----------------------
549    -- Check_Left_Paren --
550    ----------------------
551
552    --  In tone check mode (-gnatyt), left paren must not be preceded by an
553    --  identifier character or digit (a separating space is required) and
554    --  may never be followed by a space.
555
556    procedure Check_Left_Paren is
557       S : Source_Ptr;
558
559    begin
560       if Style_Check_Tokens then
561          if Token_Ptr > Source_First (Current_Source_File)
562            and then Identifier_Char (Source (Token_Ptr - 1))
563          then
564             Error_Space_Required (Token_Ptr);
565          end if;
566
567          if Source (Scan_Ptr) = ' ' then
568
569             --  Allow one or more spaces if followed by comment
570
571             S := Scan_Ptr + 1;
572             loop
573                if Source (S) = '-' and then Source (S + 1) = '-' then
574                   return;
575                elsif Source (S) /= ' ' then
576                   exit;
577                else
578                   S := S + 1;
579                end if;
580             end loop;
581
582             Error_Space_Not_Allowed (Scan_Ptr);
583          end if;
584       end if;
585    end Check_Left_Paren;
586
587    ---------------------------
588    -- Check_Line_Terminator --
589    ---------------------------
590
591    --  In check blanks at end mode (-gnatyb), lines may not end with a
592    --  trailing space.
593
594    --  In check max line length mode (-gnatym), the line length must
595    --  not exceed the permitted maximum value.
596
597    --  In check form feeds mode (-gnatyf), the line terminator may not
598    --  be either of the characters FF or VT.
599
600    procedure Check_Line_Terminator (Len : Int) is
601       S : Source_Ptr;
602
603    begin
604       --  Check FF/VT terminators
605
606       if Style_Check_Form_Feeds then
607          if Source (Scan_Ptr) = ASCII.FF then
608             Error_Msg_S ("(style) form feed not allowed");
609
610          elsif Source (Scan_Ptr) = ASCII.VT then
611             Error_Msg_S ("(style) vertical tab not allowed");
612          end if;
613       end if;
614
615       --  Check trailing space
616
617       if Style_Check_Blanks_At_End then
618          if Scan_Ptr >= First_Non_Blank_Location then
619             if Source (Scan_Ptr - 1) = ' ' then
620                S := Scan_Ptr - 1;
621
622                while Source (S - 1) = ' ' loop
623                   S := S - 1;
624                end loop;
625
626                Error_Msg ("(style) trailing spaces not permitted", S);
627             end if;
628          end if;
629       end if;
630
631       --  Check max line length
632
633       if Style_Check_Max_Line_Length then
634          if Len > Style_Max_Line_Length then
635             Error_Msg
636               ("(style) this line is too long",
637                Current_Line_Start + Source_Ptr (Style_Max_Line_Length));
638          end if;
639       end if;
640
641    end Check_Line_Terminator;
642
643    -----------------------
644    -- Check_Pragma_Name --
645    -----------------------
646
647    --  In check pragma casing mode (-gnatyp), pragma names must be mixed
648    --  case, i.e. start with an upper case letter, and otherwise lower case,
649    --  except after an underline character.
650
651    procedure Check_Pragma_Name is
652    begin
653       if Style_Check_Pragma_Casing then
654          if Determine_Token_Casing /= Mixed_Case then
655             Error_Msg_SC ("(style) bad capitalization, mixed case required");
656          end if;
657       end if;
658    end Check_Pragma_Name;
659
660    -----------------------
661    -- Check_Right_Paren --
662    -----------------------
663
664    --  In check tokens mode (-gnatyt), right paren must never be preceded by
665    --  a space unless it is the initial non-blank character on the line.
666
667    procedure Check_Right_Paren is
668    begin
669       if Style_Check_Tokens then
670          if Token_Ptr > First_Non_Blank_Location
671            and then Source (Token_Ptr - 1) = ' '
672          then
673             Error_Space_Not_Allowed (Token_Ptr - 1);
674          end if;
675       end if;
676    end Check_Right_Paren;
677
678    ---------------------
679    -- Check_Semicolon --
680    ---------------------
681
682    --  In check tokens mode (-gnatyt), semicolon does not permit a preceding
683    --  space and a following space is required.
684
685    procedure Check_Semicolon is
686    begin
687       if Style_Check_Tokens then
688          if Scan_Ptr > Source_First (Current_Source_File)
689            and then Source (Token_Ptr - 1) = ' '
690          then
691             Error_Space_Not_Allowed (Token_Ptr - 1);
692
693          elsif Source (Scan_Ptr) > ' ' then
694             Error_Space_Required (Scan_Ptr);
695          end if;
696       end if;
697    end Check_Semicolon;
698
699    ----------------
700    -- Check_Then --
701    ----------------
702
703    --  In check if then layout mode (-gnatyi), we expect a THEN keyword
704    --  to appear either on the same line as the IF, or on a separate line
705    --  after multiple conditions. In any case, it may not appear on the
706    --  line immediately following the line with the IF.
707
708    procedure Check_Then (If_Loc : Source_Ptr) is
709    begin
710       if Style_Check_If_Then_Layout then
711          if Get_Physical_Line_Number (Token_Ptr) =
712             Get_Physical_Line_Number (If_Loc) + 1
713          then
714             Error_Msg_SC ("(style) misplaced THEN");
715          end if;
716       end if;
717    end Check_Then;
718
719    -------------------------------
720    -- Check_Unary_Plus_Or_Minus --
721    -------------------------------
722
723    --  In check tokem mode (-gnatyt), unary plus or minus must not be
724    --  followed by a space.
725
726    procedure Check_Unary_Plus_Or_Minus is
727    begin
728       if Style_Check_Tokens then
729          if Source (Scan_Ptr) = ' ' then
730             Error_Space_Not_Allowed (Scan_Ptr);
731          end if;
732       end if;
733    end Check_Unary_Plus_Or_Minus;
734
735    ------------------------
736    -- Check_Vertical_Bar --
737    ------------------------
738
739    --  In check token mode (-gnatyt), vertical bar must be surrounded by spaces
740
741    procedure Check_Vertical_Bar is
742    begin
743       if Style_Check_Tokens then
744          Require_Preceding_Space;
745          Require_Following_Space;
746       end if;
747    end Check_Vertical_Bar;
748
749    -----------------------------
750    -- Error_Space_Not_Allowed --
751    -----------------------------
752
753    procedure Error_Space_Not_Allowed (S : Source_Ptr) is
754    begin
755       Error_Msg ("(style) space not allowed", S);
756    end Error_Space_Not_Allowed;
757
758    --------------------------
759    -- Error_Space_Required --
760    --------------------------
761
762    procedure Error_Space_Required (S : Source_Ptr) is
763    begin
764       Error_Msg ("(style) space required", S);
765    end Error_Space_Required;
766
767    -----------------
768    -- No_End_Name --
769    -----------------
770
771    --  In check end/exit labels mode (-gnatye), always require the name of
772    --  a subprogram or package to be present on the END, so this is an error.
773
774    procedure No_End_Name (Name : Node_Id) is
775    begin
776       if Style_Check_End_Labels then
777          Error_Msg_Node_1 := Name;
778          Error_Msg_SP ("(style) `END &` required");
779       end if;
780    end No_End_Name;
781
782    ------------------
783    -- No_Exit_Name --
784    ------------------
785
786    --  In check end/exit labels mode (-gnatye), always require the name of
787    --  the loop to be present on the EXIT when exiting a named loop.
788
789    procedure No_Exit_Name (Name : Node_Id) is
790    begin
791       if Style_Check_End_Labels then
792          Error_Msg_Node_1 := Name;
793          Error_Msg_SP ("(style) `EXIT &` required");
794       end if;
795    end No_Exit_Name;
796
797    ----------------------------
798    -- Non_Lower_Case_Keyword --
799    ----------------------------
800
801    --  In check casing mode (-gnatyk), reserved keywords must be be spelled
802    --  in all lower case (excluding keywords range, access, delta and digits
803    --  used as attribute designators).
804
805    procedure Non_Lower_Case_Keyword is
806    begin
807       if Style_Check_Keyword_Casing then
808          Error_Msg_SC ("(style) reserved words must be all lower case");
809       end if;
810    end Non_Lower_Case_Keyword;
811
812    -----------------------------
813    -- Require_Following_Space --
814    -----------------------------
815
816    procedure Require_Following_Space is
817    begin
818       if Source (Scan_Ptr) > ' ' then
819          Error_Space_Required (Scan_Ptr);
820       end if;
821    end Require_Following_Space;
822
823    -----------------------------
824    -- Require_Preceding_Space --
825    -----------------------------
826
827    procedure Require_Preceding_Space is
828    begin
829       if Token_Ptr > Source_First (Current_Source_File)
830         and then Source (Token_Ptr - 1) > ' '
831       then
832          Error_Space_Required (Token_Ptr);
833       end if;
834    end Require_Preceding_Space;
835
836    ---------------------
837    -- RM_Column_Check --
838    ---------------------
839
840    function RM_Column_Check return Boolean is
841    begin
842       return Style_Check and Style_Check_Layout;
843    end RM_Column_Check;
844
845    -----------------------------------
846    -- Subprogram_Not_In_Alpha_Order --
847    -----------------------------------
848
849    procedure Subprogram_Not_In_Alpha_Order (Name : Node_Id) is
850    begin
851       if Style_Check_Subprogram_Order then
852          Error_Msg_N
853            ("(style) subprogram body& not in alphabetical order", Name);
854       end if;
855    end Subprogram_Not_In_Alpha_Order;
856 end Style;