annotate gcc/ada/style.ads @ 138:fc828634a951

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:17:14 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S T Y L E --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This package collects all the routines used for style checking in the
kono
parents:
diff changeset
27 -- compiler, as activated by the relevant command line option. These are
kono
parents:
diff changeset
28 -- gathered in a separate package so that they can more easily be customized.
kono
parents:
diff changeset
29 -- Calls to these subprograms are only made if Opt.Style_Check is set True.
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 with Errout;
kono
parents:
diff changeset
32 with Styleg;
kono
parents:
diff changeset
33 with Types; use Types;
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 package Style is
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 procedure Body_With_No_Spec (N : Node_Id);
kono
parents:
diff changeset
38 -- Called where N is a subprogram body node for a subprogram body
kono
parents:
diff changeset
39 -- for which no spec was given, i.e. a body acting as its own spec.
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 procedure Check_Array_Attribute_Index
kono
parents:
diff changeset
42 (N : Node_Id;
kono
parents:
diff changeset
43 E1 : Node_Id;
kono
parents:
diff changeset
44 D : Int);
kono
parents:
diff changeset
45 -- Called for an array attribute specifying an index number. N is the
kono
parents:
diff changeset
46 -- node for the attribute, and E1 is the index expression (Empty if none
kono
parents:
diff changeset
47 -- present). If E1 is present, it is known to be a static integer. D is
kono
parents:
diff changeset
48 -- the number of dimensions of the array.
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 procedure Check_Identifier
kono
parents:
diff changeset
51 (Ref : Node_Or_Entity_Id;
kono
parents:
diff changeset
52 Def : Node_Or_Entity_Id);
kono
parents:
diff changeset
53 -- Check style of identifier occurrence. Ref is an N_Identifier node whose
kono
parents:
diff changeset
54 -- spelling is to be checked against the Chars spelling in identifier node
kono
parents:
diff changeset
55 -- Def (which may be either an N_Identifier, or N_Defining_Identifier node)
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 procedure Missing_Overriding (N : Node_Id; E : Entity_Id);
kono
parents:
diff changeset
58 -- Called where N is the declaration or body of an overriding operation,
kono
parents:
diff changeset
59 -- and the node does not have an overriding_indicator.
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 procedure Subprogram_Not_In_Alpha_Order (Name : Node_Id);
kono
parents:
diff changeset
62 -- Called if Name is the name of a subprogram body in a package body
kono
parents:
diff changeset
63 -- that is not in alphabetical order.
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 -- Remaining style routines come from instantiation of Styleg
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 package Style_Inst is new Styleg
kono
parents:
diff changeset
68 (Errout.Error_Msg,
kono
parents:
diff changeset
69 Errout.Error_Msg_S,
kono
parents:
diff changeset
70 Errout.Error_Msg_SC,
kono
parents:
diff changeset
71 Errout.Error_Msg_SP);
kono
parents:
diff changeset
72 -- Instantiation of Styleg for compiler use
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 procedure Check_Abs_Not
kono
parents:
diff changeset
75 renames Style_Inst.Check_Abs_Not;
kono
parents:
diff changeset
76 -- Called after scanning an ABS or NOT operator to check spacing
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 procedure Check_Apostrophe
kono
parents:
diff changeset
79 renames Style_Inst.Check_Apostrophe;
kono
parents:
diff changeset
80 -- Called after scanning an apostrophe to check spacing
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 procedure Check_Arrow (Inside_Depends : Boolean := False)
kono
parents:
diff changeset
83 renames Style_Inst.Check_Arrow;
kono
parents:
diff changeset
84 -- Called after scanning out an arrow to check spacing
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 procedure Check_Attribute_Name (Reserved : Boolean)
kono
parents:
diff changeset
87 renames Style_Inst.Check_Attribute_Name;
kono
parents:
diff changeset
88 -- The current token is an attribute designator. Check that it is
kono
parents:
diff changeset
89 -- capitalized in an appropriate manner. Reserved is set if the attribute
kono
parents:
diff changeset
90 -- designator is a reserved word (access, digits, delta or range) to allow
kono
parents:
diff changeset
91 -- differing rules for the two cases.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 procedure Check_Boolean_Operator (Node : Node_Id)
kono
parents:
diff changeset
94 renames Style_Inst.Check_Boolean_Operator;
kono
parents:
diff changeset
95 -- Called after resolving AND or OR node to check short circuit rules
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 procedure Check_Box
kono
parents:
diff changeset
98 renames Style_Inst.Check_Box;
kono
parents:
diff changeset
99 -- Called after scanning out a box to check spacing
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 procedure Check_Binary_Operator
kono
parents:
diff changeset
102 renames Style_Inst.Check_Binary_Operator;
kono
parents:
diff changeset
103 -- Called after scanning out a binary operator other than a plus, minus
kono
parents:
diff changeset
104 -- or exponentiation operator. Intended for checking spacing rules.
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 procedure Check_Exponentiation_Operator
kono
parents:
diff changeset
107 renames Style_Inst.Check_Exponentiation_Operator;
kono
parents:
diff changeset
108 -- Called after scanning out an exponentiation operator. Intended for
kono
parents:
diff changeset
109 -- checking spacing rules.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 procedure Check_Colon
kono
parents:
diff changeset
112 renames Style_Inst.Check_Colon;
kono
parents:
diff changeset
113 -- Called after scanning out colon to check spacing
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 procedure Check_Colon_Equal
kono
parents:
diff changeset
116 renames Style_Inst.Check_Colon_Equal;
kono
parents:
diff changeset
117 -- Called after scanning out colon equal to check spacing
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 procedure Check_Comma
kono
parents:
diff changeset
120 renames Style_Inst.Check_Comma;
kono
parents:
diff changeset
121 -- Called after scanning out comma to check spacing
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 procedure Check_Comment
kono
parents:
diff changeset
124 renames Style_Inst.Check_Comment;
kono
parents:
diff changeset
125 -- Called with Scan_Ptr pointing to the first minus sign of a comment.
kono
parents:
diff changeset
126 -- Intended for checking any specific rules for comment placement/format.
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 procedure Check_Dot_Dot
kono
parents:
diff changeset
129 renames Style_Inst.Check_Dot_Dot;
kono
parents:
diff changeset
130 -- Called after scanning out dot dot to check spacing
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 procedure Check_EOF
kono
parents:
diff changeset
133 renames Style_Inst.Check_EOF;
kono
parents:
diff changeset
134 -- Called after scanning out end of file mark
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 procedure Check_HT
kono
parents:
diff changeset
137 renames Style_Inst.Check_HT;
kono
parents:
diff changeset
138 -- Called with Scan_Ptr pointing to a horizontal tab character
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 procedure Check_Indentation
kono
parents:
diff changeset
141 renames Style_Inst.Check_Indentation;
kono
parents:
diff changeset
142 -- Called at the start of a new statement or declaration, with Token_Ptr
kono
parents:
diff changeset
143 -- pointing to the first token of the statement or declaration. The check
kono
parents:
diff changeset
144 -- is that the starting column is appropriate to the indentation rules if
kono
parents:
diff changeset
145 -- Token_Ptr is the first token on the line.
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 procedure Check_Left_Paren
kono
parents:
diff changeset
148 renames Style_Inst.Check_Left_Paren;
kono
parents:
diff changeset
149 -- Called after scanning out a left parenthesis to check spacing
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 procedure Check_Line_Terminator (Len : Int)
kono
parents:
diff changeset
152 renames Style_Inst.Check_Line_Terminator;
kono
parents:
diff changeset
153 -- Called with Scan_Ptr pointing to the first line terminator terminating
kono
parents:
diff changeset
154 -- the current line, used to check for appropriate line terminator and to
kono
parents:
diff changeset
155 -- check the line length (Len is the length of the current line). Note that
kono
parents:
diff changeset
156 -- the terminator may be the EOF character.
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 procedure Check_Not_In
kono
parents:
diff changeset
159 renames Style_Inst.Check_Not_In;
kono
parents:
diff changeset
160 -- Called with Scan_Ptr pointing to an IN token, and Prev_Token_Ptr
kono
parents:
diff changeset
161 -- pointing to a NOT token. Used to check proper layout of NOT IN.
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 procedure Check_Pragma_Name
kono
parents:
diff changeset
164 renames Style_Inst.Check_Pragma_Name;
kono
parents:
diff changeset
165 -- The current token is a pragma identifier. Check that it is spelled
kono
parents:
diff changeset
166 -- properly (i.e. with an appropriate casing convention).
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 procedure Check_Right_Paren
kono
parents:
diff changeset
169 renames Style_Inst.Check_Right_Paren;
kono
parents:
diff changeset
170 -- Called after scanning out a right parenthesis to check spacing
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 procedure Check_Semicolon
kono
parents:
diff changeset
173 renames Style_Inst.Check_Semicolon;
kono
parents:
diff changeset
174 -- Called after scanning out a semicolon to check spacing
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 procedure Check_Then (If_Loc : Source_Ptr)
kono
parents:
diff changeset
177 renames Style_Inst.Check_Then;
kono
parents:
diff changeset
178 -- Called to check that THEN and IF keywords are appropriately positioned.
kono
parents:
diff changeset
179 -- The parameters show the first characters of the two keywords. This
kono
parents:
diff changeset
180 -- procedure is called only if THEN appears at the start of a line with
kono
parents:
diff changeset
181 -- Token_Ptr pointing to the THEN keyword.
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 procedure Check_Unary_Plus_Or_Minus (Inside_Depends : Boolean := False)
kono
parents:
diff changeset
184 renames Style_Inst.Check_Unary_Plus_Or_Minus;
kono
parents:
diff changeset
185 -- Called after scanning a unary plus or minus to check spacing
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 procedure Check_Vertical_Bar
kono
parents:
diff changeset
188 renames Style_Inst.Check_Vertical_Bar;
kono
parents:
diff changeset
189 -- Called after scanning a vertical bar to check spacing
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 procedure Check_Xtra_Parens (Loc : Source_Ptr)
kono
parents:
diff changeset
192 renames Style_Inst.Check_Xtra_Parens;
kono
parents:
diff changeset
193 -- Called after scanning an if, case or quantified expression that has at
kono
parents:
diff changeset
194 -- least one level of parentheses around the entire expression.
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 function Mode_In_Check return Boolean
kono
parents:
diff changeset
197 renames Style_Inst.Mode_In_Check;
kono
parents:
diff changeset
198 -- Determines whether style checking is active and the Mode_In_Check is
kono
parents:
diff changeset
199 -- set, forbidding the explicit use of mode IN.
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 procedure No_End_Name (Name : Node_Id)
kono
parents:
diff changeset
202 renames Style_Inst.No_End_Name;
kono
parents:
diff changeset
203 -- Called if an END is encountered where a name is allowed but not present.
kono
parents:
diff changeset
204 -- The parameter is the node whose name is the name that is permitted in
kono
parents:
diff changeset
205 -- the END line, and the scan pointer is positioned so that if an error
kono
parents:
diff changeset
206 -- message is to be generated in this situation, it should be generated
kono
parents:
diff changeset
207 -- using Error_Msg_SP.
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 procedure No_Exit_Name (Name : Node_Id)
kono
parents:
diff changeset
210 renames Style_Inst.No_Exit_Name;
kono
parents:
diff changeset
211 -- Called when exiting a named loop, but a name is not present on the EXIT.
kono
parents:
diff changeset
212 -- The parameter is the node whose name should have followed EXIT, and the
kono
parents:
diff changeset
213 -- scan pointer is positioned so that if an error message is to be
kono
parents:
diff changeset
214 -- generated, it should be generated using Error_Msg_SP.
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 procedure Non_Lower_Case_Keyword
kono
parents:
diff changeset
217 renames Style_Inst.Non_Lower_Case_Keyword;
kono
parents:
diff changeset
218 -- Called if a reserved keyword is scanned which is not spelled in all
kono
parents:
diff changeset
219 -- lower case letters. On entry Token_Ptr points to the keyword token.
kono
parents:
diff changeset
220 -- This is not used for keywords appearing as attribute designators,
kono
parents:
diff changeset
221 -- where instead Check_Attribute_Name (True) is called.
kono
parents:
diff changeset
222 end Style;