OSDN Git Service

2007-08-31 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / usage.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               U S A G E                                  --
6 --                                                                          --
7 --                                B o d y                                   --
8 --                                                                          --
9 --          Copyright (C) 1992-2007, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 with Targparm; use Targparm;
28 with Namet;    use Namet;
29 with Opt;      use Opt;
30 with Osint;    use Osint;
31 with Output;   use Output;
32
33 with System.WCh_Con; use System.WCh_Con;
34
35 procedure Usage is
36
37    procedure Write_Switch_Char (Sw : String; Prefix : String := "gnat");
38    --  Output two spaces followed by the switch character minus followed
39    --  Prefix, followed by the string given as the argument, and then
40    --  enough blanks to tab to column 13, i.e. assuming Sw is not longer
41    --  than 5 characters, the maximum allowed, Write_Switch_Char will
42    --  always output exactly 12 characters.
43
44    -----------------------
45    -- Write_Switch_Char --
46    -----------------------
47
48    procedure Write_Switch_Char (Sw : String; Prefix : String := "gnat") is
49    begin
50       Write_Str ("  -");
51       Write_Str (Prefix);
52       Write_Str (Sw);
53
54       for J in 1 .. 12 - 3 - Prefix'Length - Sw'Length loop
55          Write_Char (' ');
56       end loop;
57    end Write_Switch_Char;
58
59 --  Start of processing for Usage
60
61 begin
62    Find_Program_Name;
63
64    --  For gnatmake, we are appending this information to the end of
65    --  the normal gnatmake output, so generate appropriate header
66
67    if Name_Len >= 8
68      and then (Name_Buffer (Name_Len - 7 .. Name_Len) = "gnatmake"
69                  or else
70                Name_Buffer (Name_Len - 7 .. Name_Len) = "GNATMAKE")
71    then
72       Write_Eol;
73       Write_Line ("Compiler switches (passed to the compiler by gnatmake):");
74
75    else
76       --  Usage line
77
78       Write_Str ("Usage: ");
79       Write_Program_Name;
80       Write_Char (' ');
81       Write_Str ("switches sfile");
82       Write_Eol;
83       Write_Eol;
84
85       --  Line for sfile
86
87       Write_Line ("  sfile     Source file name");
88    end if;
89
90    Write_Eol;
91
92    --  Common GCC switches not available in JGNAT/MGNAT
93
94    if VM_Target = No_VM then
95       Write_Switch_Char ("fstack-check ", "");
96       Write_Line ("Generate stack checking code");
97
98       Write_Switch_Char ("fno-inline   ", "");
99       Write_Line ("Inhibit all inlining (makes executable smaller)");
100    end if;
101
102    --  Common switches available to both GCC and JGNAT
103
104    Write_Switch_Char ("g            ", "");
105    Write_Line ("Generate debugging information");
106
107    Write_Switch_Char ("Idir         ", "");
108    Write_Line ("Specify source files search path");
109
110    Write_Switch_Char ("I-           ", "");
111    Write_Line ("Do not look for sources in current directory");
112
113    Write_Switch_Char ("O[0123]      ", "");
114    Write_Line ("Control the optimization level");
115
116    Write_Eol;
117
118    --  Individual lines for switches. Write_Switch_Char outputs fourteen
119    --  characters, so the remaining message is allowed to be a maximum
120    --  of 65 characters to be comfortable on an 80 character device.
121    --  If the Write_Str fits on one line, it is short enough!
122
123    --  Line for -gnata switch
124
125    Write_Switch_Char ("a");
126    Write_Line ("Assertions enabled. Pragma Assert/Debug to be activated");
127
128    --  Line for -gnatA switch
129
130    Write_Switch_Char ("A");
131    Write_Line ("Avoid processing gnat.adc, if present file will be ignored");
132
133    --  Line for -gnatb switch
134
135    Write_Switch_Char ("b");
136    Write_Line ("Generate brief messages to stderr even if verbose mode set");
137
138    --  Line for -gnatc switch
139
140    Write_Switch_Char ("c");
141    Write_Line ("Check syntax and semantics only (no code generation)");
142
143    --  Line for -gnatd switch
144
145    Write_Switch_Char ("d?");
146    Write_Line ("Compiler debug option ? ([.]a-z,A-Z,0-9), see debug.adb");
147
148    --  Line for -gnatD switch
149
150    Write_Switch_Char ("D");
151    Write_Line ("Debug expanded generated code rather than source code");
152
153    --  Line for -gnatec switch
154
155    Write_Switch_Char ("ec=?");
156    Write_Line ("Specify configuration pragmas file, e.g. -gnatec=/x/f.adc");
157
158    --  Line for -gnateD switch
159
160    Write_Switch_Char ("eD?");
161    Write_Line ("Define or redefine preprocessing symbol, e.g. -gnateDsym=val");
162
163    --  Line for -gnatef switch
164
165    Write_Switch_Char ("ef");
166    Write_Line ("Full source path in brief error messages");
167
168    --  Line for -gnateI switch
169
170    Write_Switch_Char ("eInn");
171    Write_Line ("Index in multi-unit source, e.g. -gnateI2");
172
173    --  Line for -gnatem switch
174
175    Write_Switch_Char ("em=?");
176    Write_Line ("Specify mapping file, e.g. -gnatem=mapping");
177
178    --  Line for -gnatep switch
179
180    Write_Switch_Char ("ep=?");
181    Write_Line ("Specify preprocessing data file, e.g. -gnatep=prep.data");
182
183    --  Line for -gnatE switch
184
185    Write_Switch_Char ("E");
186    Write_Line ("Dynamic elaboration checking mode enabled");
187
188    --  Line for -gnatf switch
189
190    Write_Switch_Char ("f");
191    Write_Line ("Full errors. Verbose details, all undefined references");
192
193    --  Line for -gnatF switch
194
195    Write_Switch_Char ("F");
196    Write_Line ("Force all import/export external names to all uppercase");
197
198    --  Line for -gnatg switch
199
200    Write_Switch_Char ("g");
201    Write_Line ("GNAT implementation mode (used for compiling GNAT units)");
202
203    --  Line for -gnatG switch
204
205    Write_Switch_Char ("G");
206    Write_Line ("Output generated expanded code in source form");
207
208    --  Line for -gnath switch
209
210    Write_Switch_Char ("h");
211    Write_Line ("Output this usage (help) information");
212
213    --  Line for -gnati switch
214
215    Write_Switch_Char ("i?");
216    Write_Line ("Identifier char set (?=1/2/3/4/5/8/9/p/f/n/w)");
217
218    --  Line for -gnatI switch
219
220    Write_Switch_Char ("I");
221    Write_Line ("Ignore all representation clauses");
222
223    --  Line for -gnatj switch
224
225    Write_Switch_Char ("jnn");
226    Write_Line ("Format error and warning messages to fit nn character lines");
227
228    --  Line for -gnatk switch
229
230    Write_Switch_Char ("k");
231    Write_Line ("Limit file names to nn characters (k = krunch)");
232
233    --  Lines for -gnatl switch
234
235    Write_Switch_Char ("l");
236    Write_Line ("Output full source listing with embedded error messages");
237    Write_Switch_Char ("l=f");
238    Write_Line ("Output full source listing to specified file");
239
240    --  Line for -gnatL switch
241
242    Write_Switch_Char ("L");
243    Write_Line ("List corresponding source text in -gnatG or -gnatD output");
244
245    --  Line for -gnatm switch
246
247    Write_Switch_Char ("mnn");
248    Write_Line ("Limit number of detected errors to nn (1-999999)");
249
250    --  Line for -gnatn switch
251
252    Write_Switch_Char ("n");
253    Write_Line ("Inlining of subprograms (apply pragma Inline across units)");
254
255    --  Line for -gnatN switch
256
257    Write_Switch_Char ("N");
258    Write_Line ("Full (frontend) inlining of subprograms");
259
260    --  Line for -gnato switch
261
262    Write_Switch_Char ("o");
263    Write_Line ("Enable overflow checking (off by default)");
264
265    --  Line for -gnatO switch
266
267    Write_Switch_Char ("O nm ");
268    Write_Line ("Set name of output ali file (internal switch)");
269
270    --  Line for -gnatp switch
271
272    Write_Switch_Char ("p");
273    Write_Line ("Suppress all checks");
274
275    --  Line for -gnatP switch
276
277    Write_Switch_Char ("P");
278    Write_Line ("Generate periodic calls to System.Polling.Poll");
279
280    --  Line for -gnatq switch
281
282    Write_Switch_Char ("q");
283    Write_Line ("Don't quit, try semantics, even if parse errors");
284
285    --  Line for -gnatQ switch
286
287    Write_Switch_Char ("Q");
288    Write_Line ("Don't quit, write ali/tree file even if compile errors");
289
290    --  Lines for -gnatR switch
291
292    Write_Switch_Char ("R?");
293    Write_Line ("List rep info (?=0/1/2/3 for none/types/all/variable)");
294    Write_Switch_Char ("R?s");
295    Write_Line ("List rep info to file.rep instead of standard output");
296
297    --  Lines for -gnats switch
298
299    Write_Switch_Char ("s");
300    Write_Line ("Syntax check only");
301
302    --  Lines for -gnatS switch
303
304    Write_Switch_Char ("S");
305    Write_Line ("Print listing of package Standard");
306
307    --  Lines for -gnatt switch
308
309    Write_Switch_Char ("t");
310    Write_Line ("Tree output file to be generated");
311
312    --  Line for -gnatT switch
313
314    Write_Switch_Char ("Tnn");
315    Write_Line ("All compiler tables start at nn times usual starting size");
316
317    --  Line for -gnatu switch
318
319    Write_Switch_Char ("u");
320    Write_Line ("List units for this compilation");
321
322    --  Line for -gnatU switch
323
324    Write_Switch_Char ("U");
325    Write_Line ("Enable unique tag for error messages");
326
327    --  Line for -gnatv switch
328
329    Write_Switch_Char ("v");
330    Write_Line ("Verbose mode. Full error output with source lines to stdout");
331
332    --  Line for -gnatV switch
333
334    Write_Switch_Char ("Vxx");
335    Write_Line
336      ("Enable selected validity checking mode, xx = list of parameters:");
337    Write_Line ("        a    turn on all validity checking options");
338    Write_Line ("        c    turn on checking for copies");
339    Write_Line ("        C    turn off checking for copies");
340    Write_Line ("        d    turn on default (RM) checking");
341    Write_Line ("        D    turn off default (RM) checking");
342    Write_Line ("        e    turn on checking for elementary components");
343    Write_Line ("        E    turn off checking for elementary components");
344    Write_Line ("        f    turn on checking for floating-point");
345    Write_Line ("        F    turn off checking for floating-point");
346    Write_Line ("        i    turn on checking for in params");
347    Write_Line ("        I    turn off checking for in params");
348    Write_Line ("        m    turn on checking for in out params");
349    Write_Line ("        M    turn off checking for in out params");
350    Write_Line ("        o    turn on checking for operators/attributes");
351    Write_Line ("        O    turn off checking for operators/attributes");
352    Write_Line ("        p    turn on checking for parameters");
353    Write_Line ("        P    turn off checking for parameters");
354    Write_Line ("        r    turn on checking for returns");
355    Write_Line ("        R    turn off checking for returns");
356    Write_Line ("        s    turn on checking for subscripts");
357    Write_Line ("        S    turn off checking for subscripts");
358    Write_Line ("        t    turn on checking for tests");
359    Write_Line ("        T    turn off checking for tests");
360    Write_Line ("        n    turn off all validity checks (including RM)");
361
362    --  Lines for -gnatw switch
363
364    Write_Switch_Char ("wxx");
365    Write_Line ("Enable selected warning modes, xx = list of parameters:");
366    Write_Line ("        a    turn on all optional warnings (except d,h,l,t)");
367    Write_Line ("        A    turn off all optional warnings");
368    Write_Line ("        b    turn on warnings for bad fixed value " &
369                                                   "(not multiple of small)");
370    Write_Line ("        B*   turn off warnings for bad fixed value " &
371                                                   "(not multiple of small)");
372    Write_Line ("        c    turn on warnings for constant conditional");
373    Write_Line ("        C*   turn off warnings for constant conditional");
374    Write_Line ("        .c   turn on warnings for unrepped components");
375    Write_Line ("        .C*  turn off warnings for unrepped components");
376    Write_Line ("        d    turn on warnings for implicit dereference");
377    Write_Line ("        D*   turn off warnings for implicit dereference");
378    Write_Line ("        e    treat all warnings as errors");
379    Write_Line ("        f    turn on warnings for unreferenced formal");
380    Write_Line ("        F*   turn off warnings for unreferenced formal");
381    Write_Line ("        g*   turn on warnings for unrecognized pragma");
382    Write_Line ("        G    turn off warnings for unrecognized pragma");
383    Write_Line ("        h    turn on warnings for hiding variable ");
384    Write_Line ("        H*   turn off warnings for hiding variable");
385    Write_Line ("        i*   turn on warnings for implementation unit");
386    Write_Line ("        I    turn off warnings for implementation unit");
387    Write_Line ("        j    turn on warnings for obsolescent " &
388                                                   "(annex J) feature");
389    Write_Line ("        J*   turn off warnings for obsolescent " &
390                                                   "(annex J) feature");
391    Write_Line ("        k    turn on warnings on constant variable");
392    Write_Line ("        K*   turn off warnings on constant variable");
393    Write_Line ("        l    turn on warnings for missing " &
394                                                   "elaboration pragma");
395    Write_Line ("        L*   turn off warnings for missing " &
396                                                   "elaboration pragma");
397    Write_Line ("        m    turn on warnings for variable assigned " &
398                                                   "but not read");
399    Write_Line ("        M*   turn off warnings for variable assigned " &
400                                                   "but not read");
401    Write_Line ("        n*   normal warning mode (cancels -gnatws/-gnatwe)");
402    Write_Line ("        o*   turn on warnings for address clause overlay");
403    Write_Line ("        O    turn off warnings for address clause overlay");
404    Write_Line ("        p    turn on warnings for ineffective pragma " &
405                                              "Inline in frontend");
406    Write_Line ("        P*   turn off warnings for ineffective pragma " &
407                                              "Inline in frontend");
408    Write_Line ("        q*   turn on warnings for questionable " &
409                                                   "missing parentheses");
410    Write_Line ("        Q    turn off warnings for questionable " &
411                                                   "missing parentheses");
412    Write_Line ("        r    turn on warnings for redundant construct");
413    Write_Line ("        R*   turn off warnings for redundant construct");
414    Write_Line ("        .r   turn on warnings for object renaming function");
415    Write_Line ("        .R*  turn off warnings for object renaming function");
416    Write_Line ("        s    suppress all warnings");
417    Write_Line ("        t    turn on warnings for tracking deleted code");
418    Write_Line ("        T*   turn off warnings for tracking deleted code");
419    Write_Line ("        u    turn on warnings for unused entity");
420    Write_Line ("        U*   turn off warnings for unused entity");
421    Write_Line ("        v*   turn on warnings for unassigned variable");
422    Write_Line ("        V    turn off warnings for unassigned variable");
423    Write_Line ("        w*   turn on warnings for wrong low bound assumption");
424    Write_Line ("        W    turn off warnings for wrong low bound " &
425                                                   "assumption");
426    Write_Line ("        x*   turn on warnings for export/import");
427    Write_Line ("        X    turn off warnings for export/import");
428    Write_Line ("        .x   turn on warnings for non-local exceptions");
429    Write_Line ("        .X*  turn off warnings for non-local exceptions");
430    Write_Line ("        y*   turn on warnings for Ada 2005 incompatibility");
431    Write_Line ("        Y    turn off warnings for Ada 2005 incompatibility");
432    Write_Line ("        z*   turn on convention/size/align warnings for " &
433                                                   "unchecked conversion");
434    Write_Line ("        Z    turn off convention/size/align warnings for " &
435                                                   "unchecked conversion");
436    Write_Line ("        *    indicates default in above list");
437
438    --  Line for -gnatW switch
439
440    Write_Switch_Char ("W");
441    Write_Str ("Wide character encoding method (");
442
443    for J in WC_Encoding_Method loop
444       Write_Char (WC_Encoding_Letters (J));
445
446       if J = WC_Encoding_Method'Last then
447          Write_Char (')');
448       else
449          Write_Char ('/');
450       end if;
451    end loop;
452
453    Write_Eol;
454
455    --  Line for -gnatx switch
456
457    Write_Switch_Char ("x");
458    Write_Line ("Suppress output of cross-reference information");
459
460    --  Line for -gnatX switch
461
462    Write_Switch_Char ("X");
463    Write_Line ("Language extensions permitted");
464
465    --  Lines for -gnaty switch
466
467    Write_Switch_Char ("y");
468    Write_Line ("Enable default style checks (same as -gnaty3abcefhiklmnprst)");
469    Write_Switch_Char ("yxx");
470    Write_Line ("Enable selected style checks xx = list of parameters:");
471    Write_Line ("        1-9  check indentation");
472    Write_Line ("        a    check attribute casing");
473    Write_Line ("        A    check array attribute indexes");
474    Write_Line ("        b    check no blanks at end of lines");
475    Write_Line ("        c    check comment format");
476    Write_Line ("        d    check no DOS line terminators");
477    Write_Line ("        e    check end/exit labels present");
478    Write_Line ("        f    check no form feeds/vertical tabs in source");
479    Write_Line ("        g    check standard GNAT style rules");
480    Write_Line ("        h    check no horizontal tabs in source");
481    Write_Line ("        i    check if-then layout");
482    Write_Line ("        I    check mode in");
483    Write_Line ("        k    check casing rules for keywords");
484    Write_Line ("        l    check reference manual layout");
485    Write_Line ("        Lnn  check max nest level < nn ");
486    Write_Line ("        m    check line length <= 79 characters");
487    Write_Line ("        n    check casing of package Standard identifiers");
488    Write_Line ("        Mnn  check line length <= nn characters");
489    Write_Line ("        o    check subprogram bodies in alphabetical order");
490    Write_Line ("        p    check pragma casing");
491    Write_Line ("        r    check casing for identifier references");
492    Write_Line ("        s    check separate subprogram specs present");
493    Write_Line ("        S    check separate lines after THEN or ELSE");
494    Write_Line ("        t    check token separation rules");
495    Write_Line ("        u    check no unnecessary blank lines");
496    Write_Line ("        x    check extra parentheses around conditionals");
497
498    --  Lines for -gnatyN switch
499
500    Write_Switch_Char ("yN");
501    Write_Line ("Cancel all previously set style checks");
502
503    --  Lines for -gnatz switch
504
505    Write_Switch_Char ("z");
506    Write_Line ("Distribution stub generation (r/c for receiver/caller stubs)");
507
508    --  Line for -gnat83 switch
509
510    Write_Switch_Char ("83");
511    Write_Line ("Enforce Ada 83 restrictions");
512
513    --  Line for -gnat95 switch
514
515    Write_Switch_Char ("95");
516
517    if Ada_Version_Default = Ada_95 then
518       Write_Line ("Ada 95 mode (default)");
519    else
520       Write_Line ("Enforce Ada 95 restrictions");
521    end if;
522
523    --  Line for -gnat05 switch
524
525    Write_Switch_Char ("05");
526
527    if Ada_Version_Default = Ada_05 then
528       Write_Line ("Ada 2005 mode (default)");
529    else
530       Write_Line ("Allow Ada 2005 extensions");
531    end if;
532
533 end Usage;