xref: /openbsd/gnu/usr.bin/gcc/gcc/f/top.c (revision c87b03e5)
1 /* top.c -- Implementation File (module.c template V1.0)
2    Copyright (C) 1995, 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
3    Contributed by James Craig Burley.
4 
5 This file is part of GNU Fortran.
6 
7 GNU Fortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11 
12 GNU Fortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with GNU Fortran; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
21 
22    Related Modules:
23       None.
24 
25    Description:
26       The GNU Fortran Front End.
27 
28    Modifications:
29 */
30 
31 /* Include files. */
32 
33 #include "proj.h"
34 #include "top.h"
35 #include "bad.h"
36 #include "bit.h"
37 #include "bld.h"
38 #include "com.h"
39 #include "data.h"
40 #include "equiv.h"
41 #include "expr.h"
42 #include "global.h"
43 #include "implic.h"
44 #include "info.h"
45 #include "intrin.h"
46 #include "lab.h"
47 #include "lex.h"
48 #include "malloc.h"
49 #include "name.h"
50 #include "src.h"
51 #include "st.h"
52 #include "storag.h"
53 #include "symbol.h"
54 #include "target.h"
55 #include "where.h"
56 #include "flags.h"
57 #include "toplev.h"
58 
59 /* Externals defined here. */
60 
61 bool ffe_is_do_internal_checks_ = FALSE;
62 bool ffe_is_90_ = FFETARGET_defaultIS_90;
63 bool ffe_is_automatic_ = FFETARGET_defaultIS_AUTOMATIC;
64 bool ffe_is_backslash_ = FFETARGET_defaultIS_BACKSLASH;
65 bool ffe_is_emulate_complex_ = FALSE;
66 bool ffe_is_underscoring_ = FFETARGET_defaultEXTERNAL_UNDERSCORED
67   || FFETARGET_defaultUNDERSCORED_EXTERNAL_UNDERSCORED;
68 bool ffe_is_second_underscore_ = FFETARGET_defaultUNDERSCORED_EXTERNAL_UNDERSCORED;
69 bool ffe_is_debug_kludge_ = FALSE;
70 bool ffe_is_dollar_ok_ = FFETARGET_defaultIS_DOLLAR_OK;
71 bool ffe_is_f2c_ = FFETARGET_defaultIS_F2C;
72 bool ffe_is_f2c_library_ = FFETARGET_defaultIS_F2C_LIBRARY;
73 bool ffe_is_ffedebug_ = FALSE;
74 bool ffe_is_flatten_arrays_ = FALSE;
75 bool ffe_is_free_form_ = FFETARGET_defaultIS_FREE_FORM;
76 bool ffe_is_globals_ = TRUE;
77 bool ffe_is_init_local_zero_ = FFETARGET_defaultIS_INIT_LOCAL_ZERO;
78 bool ffe_is_mainprog_;		/* TRUE if current prog unit known to be
79 				   main. */
80 bool ffe_is_onetrip_ = FALSE;
81 bool ffe_is_silent_ = TRUE;
82 bool ffe_is_typeless_boz_ = FALSE;
83 bool ffe_is_pedantic_ = FFETARGET_defaultIS_PEDANTIC;
84 bool ffe_is_saveall_;		/* TRUE if mainprog or SAVE (no args) seen. */
85 bool ffe_is_ugly_args_ = TRUE;
86 bool ffe_is_ugly_assign_ = FALSE;	/* Try and store pointer to ASSIGN labels in INTEGER vars. */
87 bool ffe_is_ugly_assumed_ = FALSE;	/* DIMENSION X([...,]1) => DIMENSION X([...,]*) */
88 bool ffe_is_ugly_comma_ = FALSE;
89 bool ffe_is_ugly_complex_ = FALSE;
90 bool ffe_is_ugly_init_ = TRUE;
91 bool ffe_is_ugly_logint_ = FALSE;
92 bool ffe_is_version_ = FALSE;
93 bool ffe_is_vxt_ = FALSE;
94 bool ffe_is_warn_globals_ = TRUE;
95 bool ffe_is_warn_implicit_ = FALSE;
96 bool ffe_is_warn_surprising_ = FALSE;
97 bool ffe_is_zeros_ = FALSE;
98 ffeCase ffe_case_intrin_ = FFETARGET_defaultCASE_INTRIN;
99 ffeCase ffe_case_match_ = FFETARGET_defaultCASE_MATCH;
100 ffeCase ffe_case_source_ = FFETARGET_defaultCASE_SOURCE;
101 ffeCase ffe_case_symbol_ = FFETARGET_defaultCASE_SYMBOL;
102 ffeIntrinsicState ffe_intrinsic_state_badu77_ = FFE_intrinsicstateENABLED;
103 ffeIntrinsicState ffe_intrinsic_state_gnu_ = FFE_intrinsicstateENABLED;
104 ffeIntrinsicState ffe_intrinsic_state_f2c_ = FFE_intrinsicstateENABLED;
105 ffeIntrinsicState ffe_intrinsic_state_f90_ = FFE_intrinsicstateENABLED;
106 ffeIntrinsicState ffe_intrinsic_state_mil_ = FFE_intrinsicstateENABLED;
107 ffeIntrinsicState ffe_intrinsic_state_unix_ = FFE_intrinsicstateENABLED;
108 ffeIntrinsicState ffe_intrinsic_state_vxt_ = FFE_intrinsicstateENABLED;
109 int ffe_fixed_line_length_ = FFETARGET_defaultFIXED_LINE_LENGTH;
110 mallocPool ffe_file_pool_ = NULL;
111 mallocPool ffe_any_unit_pool_ = NULL;
112 mallocPool ffe_program_unit_pool_ = NULL;
113 ffeCounter ffe_count_0 = 0;
114 ffeCounter ffe_count_1 = 0;
115 ffeCounter ffe_count_2 = 0;
116 ffeCounter ffe_count_3 = 0;
117 ffeCounter ffe_count_4 = 0;
118 bool ffe_in_0 = FALSE;
119 bool ffe_in_1 = FALSE;
120 bool ffe_in_2 = FALSE;
121 bool ffe_in_3 = FALSE;
122 bool ffe_in_4 = FALSE;
123 
124 /* Simple definitions and enumerations. */
125 
126 
127 /* Internal typedefs. */
128 
129 
130 /* Private include files. */
131 
132 
133 /* Internal structure definitions. */
134 
135 
136 /* Static objects accessed by functions in this module. */
137 
138 
139 /* Static functions (internal). */
140 
141 static bool ffe_is_digit_string_ (char *s);
142 
143 /* Internal macros. */
144 
145 static bool
ffe_is_digit_string_(char * s)146 ffe_is_digit_string_ (char *s)
147 {
148   char *p;
149 
150   for (p = s; ISDIGIT (*p); ++p)
151     ;
152 
153   return (p != s) && (*p == '\0');
154 }
155 
156 /* Handle command-line options.	 Returns 0 if unrecognized, 1 if
157    recognized and handled.  */
158 
159 int
ffe_decode_option(argc,argv)160 ffe_decode_option (argc, argv)
161      int argc ATTRIBUTE_UNUSED;
162      char **argv;
163 {
164   char *opt = argv[0];
165   if (opt[0] != '-')
166     return 0;
167   if (opt[1] == 'f')
168     {
169       if (strcmp (&opt[2], "version") == 0)
170 	{
171 	  ffe_set_is_version (TRUE);
172 	  ffe_set_is_do_internal_checks (TRUE);
173 	}
174       else if (strcmp (&opt[2], "f66") == 0)
175 	{
176 	  ffe_set_is_onetrip (TRUE);
177 	  ffe_set_is_ugly_assumed (TRUE);
178 	}
179       else if (strcmp (&opt[2], "no-f66") == 0)
180 	{
181 	  ffe_set_is_onetrip (FALSE);
182 	  ffe_set_is_ugly_assumed (FALSE);
183 	}
184       else if (strcmp (&opt[2], "f77") == 0)
185 	{
186 	  ffe_set_is_backslash (TRUE);
187 	  ffe_set_is_typeless_boz (FALSE);
188 	}
189       else if (strcmp (&opt[2], "no-f77") == 0)
190 	{
191 	  ffe_set_is_backslash (FALSE);
192 	}
193       else if (strcmp (&opt[2], "f90") == 0)
194 	ffe_set_is_90 (TRUE);
195       else if (strcmp (&opt[2], "no-f90") == 0)
196 	ffe_set_is_90 (FALSE);
197       else if (strcmp (&opt[2], "automatic") == 0)
198 	ffe_set_is_automatic (TRUE);
199       else if (strcmp (&opt[2], "no-automatic") == 0)
200 	ffe_set_is_automatic (FALSE);
201       else if (strcmp (&opt[2], "dollar-ok") == 0)
202 	ffe_set_is_dollar_ok (TRUE);
203       else if (strcmp (&opt[2], "no-dollar-ok") == 0)
204 	ffe_set_is_dollar_ok (FALSE);
205       else if (strcmp (&opt[2], "f2c") == 0)
206 	ffe_set_is_f2c (TRUE);
207       else if (strcmp (&opt[2], "no-f2c") == 0)
208 	ffe_set_is_f2c (FALSE);
209       else if (strcmp (&opt[2], "f2c-library") == 0)
210 	ffe_set_is_f2c_library (TRUE);
211       else if (strcmp (&opt[2], "no-f2c-library") == 0)
212 	ffe_set_is_f2c_library (FALSE);
213       else if (strcmp (&opt[2], "flatten-arrays") == 0)
214 	ffe_set_is_flatten_arrays (TRUE);
215       else if (strcmp (&opt[2], "no-flatten-arrays") == 0)
216 	ffe_set_is_flatten_arrays (FALSE);
217       else if (strcmp (&opt[2], "free-form") == 0)
218 	ffe_set_is_free_form (TRUE);
219       else if (strcmp (&opt[2], "no-free-form") == 0)
220 	ffe_set_is_free_form (FALSE);
221       else if (strcmp (&opt[2], "fixed-form") == 0)
222 	{
223 	  ffe_set_is_free_form (FALSE);
224 	  return -1;
225 	}
226       else if (strcmp (&opt[2], "no-fixed-form") == 0)
227 	ffe_set_is_free_form (TRUE);
228       else if (strcmp (&opt[2], "pedantic") == 0)
229 	ffe_set_is_pedantic (TRUE);
230       else if (strcmp (&opt[2], "no-pedantic") == 0)
231 	ffe_set_is_pedantic (FALSE);
232       else if (strcmp (&opt[2], "vxt") == 0)
233 	ffe_set_is_vxt (TRUE);
234       else if (strcmp (&opt[2], "not-vxt") == 0)
235 	ffe_set_is_vxt (FALSE);
236       else if (strcmp (&opt[2], "vxt-not-f90") == 0)
237 	warning ("%s no longer supported -- try -fvxt", opt);
238       else if (strcmp (&opt[2], "f90-not-vxt") == 0)
239 	warning ("%s no longer supported -- try -fno-vxt -ff90", opt);
240       else if (strcmp (&opt[2], "no-ugly") == 0)
241 	{
242 	  ffe_set_is_ugly_args (FALSE);
243 	  ffe_set_is_ugly_assign (FALSE);
244 	  ffe_set_is_ugly_assumed (FALSE);
245 	  ffe_set_is_ugly_comma (FALSE);
246 	  ffe_set_is_ugly_complex (FALSE);
247 	  ffe_set_is_ugly_init (FALSE);
248 	  ffe_set_is_ugly_logint (FALSE);
249 	}
250       else if (strcmp (&opt[2], "ugly-args") == 0)
251 	ffe_set_is_ugly_args (TRUE);
252       else if (strcmp (&opt[2], "no-ugly-args") == 0)
253 	ffe_set_is_ugly_args (FALSE);
254       else if (strcmp (&opt[2], "ugly-assign") == 0)
255 	ffe_set_is_ugly_assign (TRUE);
256       else if (strcmp (&opt[2], "no-ugly-assign") == 0)
257 	ffe_set_is_ugly_assign (FALSE);
258       else if (strcmp (&opt[2], "ugly-assumed") == 0)
259 	ffe_set_is_ugly_assumed (TRUE);
260       else if (strcmp (&opt[2], "no-ugly-assumed") == 0)
261 	ffe_set_is_ugly_assumed (FALSE);
262       else if (strcmp (&opt[2], "ugly-comma") == 0)
263 	ffe_set_is_ugly_comma (TRUE);
264       else if (strcmp (&opt[2], "no-ugly-comma") == 0)
265 	ffe_set_is_ugly_comma (FALSE);
266       else if (strcmp (&opt[2], "ugly-complex") == 0)
267 	ffe_set_is_ugly_complex (TRUE);
268       else if (strcmp (&opt[2], "no-ugly-complex") == 0)
269 	ffe_set_is_ugly_complex (FALSE);
270       else if (strcmp (&opt[2], "ugly-init") == 0)
271 	ffe_set_is_ugly_init (TRUE);
272       else if (strcmp (&opt[2], "no-ugly-init") == 0)
273 	ffe_set_is_ugly_init (FALSE);
274       else if (strcmp (&opt[2], "ugly-logint") == 0)
275 	ffe_set_is_ugly_logint (TRUE);
276       else if (strcmp (&opt[2], "no-ugly-logint") == 0)
277 	ffe_set_is_ugly_logint (FALSE);
278       else if (strcmp (&opt[2], "xyzzy") == 0)
279 	ffe_set_is_ffedebug (TRUE);
280       else if (strcmp (&opt[2], "no-xyzzy") == 0)
281 	ffe_set_is_ffedebug (FALSE);
282       else if (strcmp (&opt[2], "init-local-zero") == 0)
283 	ffe_set_is_init_local_zero (TRUE);
284       else if (strcmp (&opt[2], "no-init-local-zero") == 0)
285 	ffe_set_is_init_local_zero (FALSE);
286       else if (strcmp (&opt[2], "emulate-complex") == 0)
287 	ffe_set_is_emulate_complex (TRUE);
288       else if (strcmp (&opt[2], "no-emulate-complex") == 0)
289 	ffe_set_is_emulate_complex (FALSE);
290       else if (strcmp (&opt[2], "backslash") == 0)
291 	ffe_set_is_backslash (TRUE);
292       else if (strcmp (&opt[2], "no-backslash") == 0)
293 	ffe_set_is_backslash (FALSE);
294       else if (strcmp (&opt[2], "underscoring") == 0)
295 	ffe_set_is_underscoring (TRUE);
296       else if (strcmp (&opt[2], "no-underscoring") == 0)
297 	ffe_set_is_underscoring (FALSE);
298       else if (strcmp (&opt[2], "second-underscore") == 0)
299 	ffe_set_is_second_underscore (TRUE);
300       else if (strcmp (&opt[2], "no-second-underscore") == 0)
301 	ffe_set_is_second_underscore (FALSE);
302       else if (strcmp (&opt[2], "zeros") == 0)
303 	ffe_set_is_zeros (TRUE);
304       else if (strcmp (&opt[2], "no-zeros") == 0)
305 	ffe_set_is_zeros (FALSE);
306       else if (strcmp (&opt[2], "debug-kludge") == 0)
307 	warning ("%s disabled, use normal debugging flags", opt);
308       else if (strcmp (&opt[2], "no-debug-kludge") == 0)
309 	warning ("%s disabled, use normal debugging flags", opt);
310       else if (strcmp (&opt[2], "onetrip") == 0)
311 	ffe_set_is_onetrip (TRUE);
312       else if (strcmp (&opt[2], "no-onetrip") == 0)
313 	ffe_set_is_onetrip (FALSE);
314       else if (strcmp (&opt[2], "silent") == 0)
315 	ffe_set_is_silent (TRUE);
316       else if (strcmp (&opt[2], "no-silent") == 0)
317 	ffe_set_is_silent (FALSE);
318       else if (strcmp (&opt[2], "globals") == 0)
319 	ffe_set_is_globals (TRUE);
320       else if (strcmp (&opt[2], "no-globals") == 0)
321 	ffe_set_is_globals (FALSE);
322       else if (strcmp (&opt[2], "fortran-bounds-check") == 0)
323 	flag_bounds_check = TRUE;
324       else if (strcmp (&opt[2], "no-fortran-bounds-check") == 0)
325 	flag_bounds_check = FALSE;
326       else if (strcmp (&opt[2], "typeless-boz") == 0)
327 	ffe_set_is_typeless_boz (TRUE);
328       else if (strcmp (&opt[2], "no-typeless-boz") == 0)
329 	ffe_set_is_typeless_boz (FALSE);
330       else if (strcmp (&opt[2], "intrin-case-initcap") == 0)
331 	ffe_set_case_intrin (FFE_caseINITCAP);
332       else if (strcmp (&opt[2], "intrin-case-upper") == 0)
333 	ffe_set_case_intrin (FFE_caseUPPER);
334       else if (strcmp (&opt[2], "intrin-case-lower") == 0)
335 	ffe_set_case_intrin (FFE_caseLOWER);
336       else if (strcmp (&opt[2], "intrin-case-any") == 0)
337 	ffe_set_case_intrin (FFE_caseNONE);
338       else if (strcmp (&opt[2], "match-case-initcap") == 0)
339 	ffe_set_case_match (FFE_caseINITCAP);
340       else if (strcmp (&opt[2], "match-case-upper") == 0)
341 	ffe_set_case_match (FFE_caseUPPER);
342       else if (strcmp (&opt[2], "match-case-lower") == 0)
343 	ffe_set_case_match (FFE_caseLOWER);
344       else if (strcmp (&opt[2], "match-case-any") == 0)
345 	ffe_set_case_match (FFE_caseNONE);
346       else if (strcmp (&opt[2], "source-case-upper") == 0)
347 	ffe_set_case_source (FFE_caseUPPER);
348       else if (strcmp (&opt[2], "source-case-lower") == 0)
349 	ffe_set_case_source (FFE_caseLOWER);
350       else if (strcmp (&opt[2], "source-case-preserve") == 0)
351 	ffe_set_case_source (FFE_caseNONE);
352       else if (strcmp (&opt[2], "symbol-case-initcap") == 0)
353 	ffe_set_case_symbol (FFE_caseINITCAP);
354       else if (strcmp (&opt[2], "symbol-case-upper") == 0)
355 	ffe_set_case_symbol (FFE_caseUPPER);
356       else if (strcmp (&opt[2], "symbol-case-lower") == 0)
357 	ffe_set_case_symbol (FFE_caseLOWER);
358       else if (strcmp (&opt[2], "symbol-case-any") == 0)
359 	ffe_set_case_symbol (FFE_caseNONE);
360       else if (strcmp (&opt[2], "case-strict-upper") == 0)
361 	{
362 	  ffe_set_case_intrin (FFE_caseUPPER);
363 	  ffe_set_case_match (FFE_caseUPPER);
364 	  ffe_set_case_source (FFE_caseNONE);
365 	  ffe_set_case_symbol (FFE_caseUPPER);
366 	}
367       else if (strcmp (&opt[2], "case-strict-lower") == 0)
368 	{
369 	  ffe_set_case_intrin (FFE_caseLOWER);
370 	  ffe_set_case_match (FFE_caseLOWER);
371 	  ffe_set_case_source (FFE_caseNONE);
372 	  ffe_set_case_symbol (FFE_caseLOWER);
373 	}
374       else if (strcmp (&opt[2], "case-initcap") == 0)
375 	{
376 	  ffe_set_case_intrin (FFE_caseINITCAP);
377 	  ffe_set_case_match (FFE_caseINITCAP);
378 	  ffe_set_case_source (FFE_caseNONE);
379 	  ffe_set_case_symbol (FFE_caseINITCAP);
380 	}
381       else if (strcmp (&opt[2], "case-upper") == 0)
382 	{
383 	  ffe_set_case_intrin (FFE_caseNONE);
384 	  ffe_set_case_match (FFE_caseNONE);
385 	  ffe_set_case_source (FFE_caseUPPER);
386 	  ffe_set_case_symbol (FFE_caseNONE);
387 	}
388       else if (strcmp (&opt[2], "case-lower") == 0)
389 	{
390 	  ffe_set_case_intrin (FFE_caseNONE);
391 	  ffe_set_case_match (FFE_caseNONE);
392 	  ffe_set_case_source (FFE_caseLOWER);
393 	  ffe_set_case_symbol (FFE_caseNONE);
394 	}
395       else if (strcmp (&opt[2], "case-preserve") == 0)
396 	{
397 	  ffe_set_case_intrin (FFE_caseNONE);
398 	  ffe_set_case_match (FFE_caseNONE);
399 	  ffe_set_case_source (FFE_caseNONE);
400 	  ffe_set_case_symbol (FFE_caseNONE);
401 	}
402       else if (strcmp (&opt[2], "badu77-intrinsics-delete") == 0)
403 	ffe_set_intrinsic_state_badu77 (FFE_intrinsicstateDELETED);
404       else if (strcmp (&opt[2], "badu77-intrinsics-hide") == 0)
405 	ffe_set_intrinsic_state_badu77 (FFE_intrinsicstateHIDDEN);
406       else if (strcmp (&opt[2], "badu77-intrinsics-disable") == 0)
407 	ffe_set_intrinsic_state_badu77 (FFE_intrinsicstateDISABLED);
408       else if (strcmp (&opt[2], "badu77-intrinsics-enable") == 0)
409 	ffe_set_intrinsic_state_badu77 (FFE_intrinsicstateENABLED);
410       else if (strcmp (&opt[2], "gnu-intrinsics-delete") == 0)
411 	ffe_set_intrinsic_state_gnu (FFE_intrinsicstateDELETED);
412       else if (strcmp (&opt[2], "gnu-intrinsics-hide") == 0)
413 	ffe_set_intrinsic_state_gnu (FFE_intrinsicstateHIDDEN);
414       else if (strcmp (&opt[2], "gnu-intrinsics-disable") == 0)
415 	ffe_set_intrinsic_state_gnu (FFE_intrinsicstateDISABLED);
416       else if (strcmp (&opt[2], "gnu-intrinsics-enable") == 0)
417 	ffe_set_intrinsic_state_gnu (FFE_intrinsicstateENABLED);
418       else if (strcmp (&opt[2], "f2c-intrinsics-delete") == 0)
419 	ffe_set_intrinsic_state_f2c (FFE_intrinsicstateDELETED);
420       else if (strcmp (&opt[2], "f2c-intrinsics-hide") == 0)
421 	ffe_set_intrinsic_state_f2c (FFE_intrinsicstateHIDDEN);
422       else if (strcmp (&opt[2], "f2c-intrinsics-disable") == 0)
423 	ffe_set_intrinsic_state_f2c (FFE_intrinsicstateDISABLED);
424       else if (strcmp (&opt[2], "f2c-intrinsics-enable") == 0)
425 	ffe_set_intrinsic_state_f2c (FFE_intrinsicstateENABLED);
426       else if (strcmp (&opt[2], "f90-intrinsics-delete") == 0)
427 	ffe_set_intrinsic_state_f90 (FFE_intrinsicstateDELETED);
428       else if (strcmp (&opt[2], "f90-intrinsics-hide") == 0)
429 	ffe_set_intrinsic_state_f90 (FFE_intrinsicstateHIDDEN);
430       else if (strcmp (&opt[2], "f90-intrinsics-disable") == 0)
431 	ffe_set_intrinsic_state_f90 (FFE_intrinsicstateDISABLED);
432       else if (strcmp (&opt[2], "f90-intrinsics-enable") == 0)
433 	ffe_set_intrinsic_state_f90 (FFE_intrinsicstateENABLED);
434       else if (strcmp (&opt[2], "mil-intrinsics-delete") == 0)
435 	ffe_set_intrinsic_state_mil (FFE_intrinsicstateDELETED);
436       else if (strcmp (&opt[2], "mil-intrinsics-hide") == 0)
437 	ffe_set_intrinsic_state_mil (FFE_intrinsicstateHIDDEN);
438       else if (strcmp (&opt[2], "mil-intrinsics-disable") == 0)
439 	ffe_set_intrinsic_state_mil (FFE_intrinsicstateDISABLED);
440       else if (strcmp (&opt[2], "mil-intrinsics-enable") == 0)
441 	ffe_set_intrinsic_state_mil (FFE_intrinsicstateENABLED);
442       else if (strcmp (&opt[2], "unix-intrinsics-delete") == 0)
443 	ffe_set_intrinsic_state_unix (FFE_intrinsicstateDELETED);
444       else if (strcmp (&opt[2], "unix-intrinsics-hide") == 0)
445 	ffe_set_intrinsic_state_unix (FFE_intrinsicstateHIDDEN);
446       else if (strcmp (&opt[2], "unix-intrinsics-disable") == 0)
447 	ffe_set_intrinsic_state_unix (FFE_intrinsicstateDISABLED);
448       else if (strcmp (&opt[2], "unix-intrinsics-enable") == 0)
449 	ffe_set_intrinsic_state_unix (FFE_intrinsicstateENABLED);
450       else if (strcmp (&opt[2], "vxt-intrinsics-delete") == 0)
451 	ffe_set_intrinsic_state_vxt (FFE_intrinsicstateDELETED);
452       else if (strcmp (&opt[2], "vxt-intrinsics-hide") == 0)
453 	ffe_set_intrinsic_state_vxt (FFE_intrinsicstateHIDDEN);
454       else if (strcmp (&opt[2], "vxt-intrinsics-disable") == 0)
455 	ffe_set_intrinsic_state_vxt (FFE_intrinsicstateDISABLED);
456       else if (strcmp (&opt[2], "vxt-intrinsics-enable") == 0)
457 	ffe_set_intrinsic_state_vxt (FFE_intrinsicstateENABLED);
458       else if (strncmp (&opt[2], "fixed-line-length-",
459 			strlen ("fixed-line-length-")) == 0)
460 	{
461 	  char *len = &opt[2] + strlen ("fixed-line-length-");
462 
463 	  if (strcmp (len, "none") == 0)
464 	    {
465 	      ffe_set_fixed_line_length (0);
466 	      return -1;
467 	    }
468 	  else if (ffe_is_digit_string_ (len))
469 	    {
470 	      ffe_set_fixed_line_length (atol (len));
471 	      return -1;
472 	    }
473 	  else
474 	    return 0;
475 	}
476       else
477 	return 0;
478     }
479   else if (opt[1] == 'W')
480     {
481       if (!strcmp (&opt[2], "comment"))
482 	; /* cpp handles this one.  */
483       else if (!strcmp (&opt[2], "no-comment"))
484 	; /* cpp handles this one.  */
485       else if (!strcmp (&opt[2], "comments"))
486 	; /* cpp handles this one.  */
487       else if (!strcmp (&opt[2], "no-comments"))
488 	; /* cpp handles this one.  */
489       else if (!strcmp (&opt[2], "trigraphs"))
490 	; /* cpp handles this one.  */
491       else if (!strcmp (&opt[2], "no-trigraphs"))
492 	; /* cpp handles this one.  */
493       else if (!strcmp (&opt[2], "import"))
494 	; /* cpp handles this one.  */
495       else if (!strcmp (&opt[2], "no-import"))
496 	; /* cpp handles this one.  */
497       else if (!strcmp (&opt[2], "globals"))
498 	ffe_set_is_warn_globals (TRUE);
499       else if (!strcmp (&opt[2], "no-globals"))
500 	ffe_set_is_warn_globals (FALSE);
501       else if (!strcmp (&opt[2], "implicit"))
502 	ffe_set_is_warn_implicit (TRUE);
503       else if (!strcmp (&opt[2], "no-implicit"))
504 	ffe_set_is_warn_implicit (FALSE);
505       else if (!strcmp (&opt[2], "surprising"))
506 	ffe_set_is_warn_surprising (TRUE);
507       else if (!strcmp (&opt[2], "no-surprising"))
508 	ffe_set_is_warn_surprising (FALSE);
509       else if (!strcmp (&opt[2], "all"))
510 	{
511 	  /* We save the value of warn_uninitialized, since if they put
512 	     -Wuninitialized on the command line, we need to generate a
513 	     warning about not using it without also specifying -O.  */
514 	  if (warn_uninitialized != 1)
515 	    warn_uninitialized = 2;
516 	  set_Wunused (1);
517 	}
518       else
519 	return 0;
520     }
521   else if (opt[1] == 'I')
522     return ffecom_decode_include_option (&opt[2]);
523   else
524     return 0;
525 
526   return 1;
527 }
528 
529 /* Run the FFE on a source file (not an INCLUDEd file).
530 
531    Runs the whole shebang.
532 
533    Prepare and invoke the appropriate lexer.  */
534 
535 void
ffe_file(ffewhereFile wf,FILE * f)536 ffe_file (ffewhereFile wf, FILE *f)
537 {
538   ffe_init_1 ();
539   ffelex_set_handler ((ffelexHandler) ffest_first);
540   ffewhere_file_set (wf, TRUE, 0);
541   if (ffe_is_free_form_)
542     ffelex_file_free (wf, f);
543   else
544     ffelex_file_fixed (wf, f);
545   ffest_eof ();
546   ffe_terminate_1 ();
547 }
548 
549 /* ffe_init_0 -- Initialize the FFE per image invocation
550 
551    ffe_init_0();
552 
553    Performs per-image invocation.  */
554 
555 void
ffe_init_0()556 ffe_init_0 ()
557 {
558   ++ffe_count_0;
559   ffe_in_0 = TRUE;
560 
561   ffebad_init_0 ();
562   ffebit_init_0 ();
563   ffebld_init_0 ();
564   ffecom_init_0 ();
565   ffedata_init_0 ();
566   ffeequiv_init_0 ();
567   ffeexpr_init_0 ();
568   ffeglobal_init_0 ();
569   ffeimplic_init_0 ();
570   ffeinfo_init_0 ();
571   ffeintrin_init_0 ();
572   ffelab_init_0 ();
573   ffelex_init_0 ();
574   ffename_init_0 ();
575   ffesrc_init_0 ();
576   ffest_init_0 ();
577   ffestorag_init_0 ();
578   ffesymbol_init_0 ();
579   ffetarget_init_0 ();
580   ffetype_init_0 ();
581   ffewhere_init_0 ();
582 }
583 
584 /* ffe_init_1 -- Initialize the FFE per source file
585 
586    ffe_init_1();
587 
588    Performs per-source-file invocation (not including INCLUDEd files).	*/
589 
590 void
ffe_init_1()591 ffe_init_1 ()
592 {
593   ++ffe_count_1;
594   ffe_in_1 = TRUE;
595 
596   assert (ffe_file_pool_ == NULL);
597   ffe_file_pool_ = malloc_pool_new ("File", malloc_pool_image (), 1024);
598 
599   ffebad_init_1 ();
600   ffebit_init_1 ();
601   ffebld_init_1 ();
602   ffecom_init_1 ();
603   ffedata_init_1 ();
604   ffeequiv_init_1 ();
605   ffeexpr_init_1 ();
606   ffeglobal_init_1 ();
607   ffeimplic_init_1 ();
608   ffeinfo_init_1 ();
609   ffeintrin_init_1 ();
610   ffelab_init_1 ();
611   ffelex_init_1 ();
612   ffename_init_1 ();
613   ffesrc_init_1 ();
614   ffest_init_1 ();
615   ffestorag_init_1 ();
616   ffesymbol_init_1 ();
617   ffetarget_init_1 ();
618   ffetype_init_1 ();
619   ffewhere_init_1 ();
620 
621   ffe_init_2 ();
622 }
623 
624 /* ffe_init_2 -- Initialize the FFE per outer program unit
625 
626    ffe_init_2();
627 
628    Performs per-program-unit invocation.  */
629 
630 void
ffe_init_2()631 ffe_init_2 ()
632 {
633   ++ffe_count_2;
634   ffe_in_2 = TRUE;
635 
636   assert (ffe_program_unit_pool_ == NULL);
637   ffe_program_unit_pool_ = malloc_pool_new ("Program unit", ffe_file_pool_, 1024);
638   ffe_is_mainprog_ = FALSE;
639   ffe_is_saveall_ = !ffe_is_automatic_;
640 
641   ffebad_init_2 ();
642   ffebit_init_2 ();
643   ffebld_init_2 ();
644   ffecom_init_2 ();
645   ffedata_init_2 ();
646   ffeequiv_init_2 ();
647   ffeexpr_init_2 ();
648   ffeglobal_init_2 ();
649   ffeimplic_init_2 ();
650   ffeinfo_init_2 ();
651   ffeintrin_init_2 ();
652   ffelab_init_2 ();
653   ffelex_init_2 ();
654   ffename_init_2 ();
655   ffesrc_init_2 ();
656   ffest_init_2 ();
657   ffestorag_init_2 ();
658   ffesymbol_init_2 ();
659   ffetarget_init_2 ();
660   ffetype_init_2 ();
661   ffewhere_init_2 ();
662 
663   ffe_init_3 ();
664 }
665 
666 /* ffe_init_3 -- Initialize the FFE per any program unit
667 
668    ffe_init_3();
669 
670    Performs per-any-unit initialization; does NOT do
671    per-statement-function-definition initialization (i.e. the chain
672    of inits, from 0-3, breaks here; level 4 must be invoked independently).  */
673 
674 void
ffe_init_3()675 ffe_init_3 ()
676 {
677   ++ffe_count_3;
678   ffe_in_3 = TRUE;
679 
680   assert (ffe_any_unit_pool_ == NULL);
681   ffe_any_unit_pool_ = malloc_pool_new ("Any unit", ffe_program_unit_pool_, 1024);
682 
683   ffebad_init_3 ();
684   ffebit_init_3 ();
685   ffebld_init_3 ();
686   ffecom_init_3 ();
687   ffedata_init_3 ();
688   ffeequiv_init_3 ();
689   ffeexpr_init_3 ();
690   ffeglobal_init_3 ();
691   ffeimplic_init_3 ();
692   ffeinfo_init_3 ();
693   ffeintrin_init_3 ();
694   ffelab_init_3 ();
695   ffelex_init_3 ();
696   ffename_init_3 ();
697   ffesrc_init_3 ();
698   ffest_init_3 ();
699   ffestorag_init_3 ();
700   ffesymbol_init_3 ();
701   ffetarget_init_3 ();
702   ffetype_init_3 ();
703   ffewhere_init_3 ();
704 }
705 
706 /* ffe_init_4 -- Initialize the FFE per statement function definition
707 
708    ffe_init_4();  */
709 
710 void
ffe_init_4()711 ffe_init_4 ()
712 {
713   ++ffe_count_4;
714   ffe_in_4 = TRUE;
715 
716   ffebad_init_4 ();
717   ffebit_init_4 ();
718   ffebld_init_4 ();
719   ffecom_init_4 ();
720   ffedata_init_4 ();
721   ffeequiv_init_4 ();
722   ffeexpr_init_4 ();
723   ffeglobal_init_4 ();
724   ffeimplic_init_4 ();
725   ffeinfo_init_4 ();
726   ffeintrin_init_4 ();
727   ffelab_init_4 ();
728   ffelex_init_4 ();
729   ffename_init_4 ();
730   ffesrc_init_4 ();
731   ffest_init_4 ();
732   ffestorag_init_4 ();
733   ffesymbol_init_4 ();
734   ffetarget_init_4 ();
735   ffetype_init_4 ();
736   ffewhere_init_4 ();
737 }
738 
739 /* ffe_terminate_0 -- Terminate the FFE prior to image termination
740 
741    ffe_terminate_0();  */
742 
743 void
ffe_terminate_0()744 ffe_terminate_0 ()
745 {
746   ffe_count_1 = 0;
747   ffe_in_0 = FALSE;
748 
749   ffebad_terminate_0 ();
750   ffebit_terminate_0 ();
751   ffebld_terminate_0 ();
752   ffecom_terminate_0 ();
753   ffedata_terminate_0 ();
754   ffeequiv_terminate_0 ();
755   ffeexpr_terminate_0 ();
756   ffeglobal_terminate_0 ();
757   ffeimplic_terminate_0 ();
758   ffeinfo_terminate_0 ();
759   ffeintrin_terminate_0 ();
760   ffelab_terminate_0 ();
761   ffelex_terminate_0 ();
762   ffename_terminate_0 ();
763   ffesrc_terminate_0 ();
764   ffest_terminate_0 ();
765   ffestorag_terminate_0 ();
766   ffesymbol_terminate_0 ();
767   ffetarget_terminate_0 ();
768   ffetype_terminate_0 ();
769   ffewhere_terminate_0 ();
770 }
771 
772 /* ffe_terminate_1 -- Terminate the FFE after seeing source file EOF
773 
774    ffe_terminate_1();  */
775 
776 void
ffe_terminate_1()777 ffe_terminate_1 ()
778 {
779   ffe_count_2 = 0;
780   ffe_in_1 = FALSE;
781 
782   ffe_terminate_2 ();
783 
784   ffebad_terminate_1 ();
785   ffebit_terminate_1 ();
786   ffebld_terminate_1 ();
787   ffecom_terminate_1 ();
788   ffedata_terminate_1 ();
789   ffeequiv_terminate_1 ();
790   ffeexpr_terminate_1 ();
791   ffeglobal_terminate_1 ();
792   ffeimplic_terminate_1 ();
793   ffeinfo_terminate_1 ();
794   ffeintrin_terminate_1 ();
795   ffelab_terminate_1 ();
796   ffelex_terminate_1 ();
797   ffename_terminate_1 ();
798   ffesrc_terminate_1 ();
799   ffest_terminate_1 ();
800   ffestorag_terminate_1 ();
801   ffesymbol_terminate_1 ();
802   ffetarget_terminate_1 ();
803   ffetype_terminate_1 ();
804   ffewhere_terminate_1 ();
805 
806   assert (ffe_file_pool_ != NULL);
807   malloc_pool_kill (ffe_file_pool_);
808   ffe_file_pool_ = NULL;
809 }
810 
811 /* ffe_terminate_2 -- Terminate the FFE after seeing outer program unit END
812 
813    ffe_terminate_2();  */
814 
815 void
ffe_terminate_2()816 ffe_terminate_2 ()
817 {
818   ffe_count_3 = 0;
819   ffe_in_2 = FALSE;
820 
821   ffe_terminate_3 ();
822 
823   ffebad_terminate_2 ();
824   ffebit_terminate_2 ();
825   ffebld_terminate_2 ();
826   ffecom_terminate_2 ();
827   ffedata_terminate_2 ();
828   ffeequiv_terminate_2 ();
829   ffeexpr_terminate_2 ();
830   ffeglobal_terminate_2 ();
831   ffeimplic_terminate_2 ();
832   ffeinfo_terminate_2 ();
833   ffeintrin_terminate_2 ();
834   ffelab_terminate_2 ();
835   ffelex_terminate_2 ();
836   ffename_terminate_2 ();
837   ffesrc_terminate_2 ();
838   ffest_terminate_2 ();
839   ffestorag_terminate_2 ();
840   ffesymbol_terminate_2 ();
841   ffetarget_terminate_2 ();
842   ffetype_terminate_2 ();
843   ffewhere_terminate_2 ();
844 
845   assert (ffe_program_unit_pool_ != NULL);
846   malloc_pool_kill (ffe_program_unit_pool_);
847   ffe_program_unit_pool_ = NULL;
848 }
849 
850 /* ffe_terminate_3 -- Terminate the FFE after seeing any program unit END
851 
852    ffe_terminate_3();  */
853 
854 void
ffe_terminate_3()855 ffe_terminate_3 ()
856 {
857   ffe_count_4 = 0;
858   ffe_in_3 = FALSE;
859 
860   ffebad_terminate_3 ();
861   ffebit_terminate_3 ();
862   ffebld_terminate_3 ();
863   ffecom_terminate_3 ();
864   ffedata_terminate_3 ();
865   ffeequiv_terminate_3 ();
866   ffeexpr_terminate_3 ();
867   ffeglobal_terminate_3 ();
868   ffeimplic_terminate_3 ();
869   ffeinfo_terminate_3 ();
870   ffeintrin_terminate_3 ();
871   ffelab_terminate_3 ();
872   ffelex_terminate_3 ();
873   ffename_terminate_3 ();
874   ffesrc_terminate_3 ();
875   ffest_terminate_3 ();
876   ffestorag_terminate_3 ();
877   ffesymbol_terminate_3 ();
878   ffetarget_terminate_3 ();
879   ffetype_terminate_3 ();
880   ffewhere_terminate_3 ();
881 
882   assert (ffe_any_unit_pool_ != NULL);
883   malloc_pool_kill (ffe_any_unit_pool_);
884   ffe_any_unit_pool_ = NULL;
885 }
886 
887 /* ffe_terminate_4 -- Terminate the FFE after seeing sfunc def expression
888 
889    ffe_terminate_4();  */
890 
891 void
ffe_terminate_4()892 ffe_terminate_4 ()
893 {
894   ffe_in_4 = FALSE;
895 
896   ffebad_terminate_4 ();
897   ffebit_terminate_4 ();
898   ffebld_terminate_4 ();
899   ffecom_terminate_4 ();
900   ffedata_terminate_4 ();
901   ffeequiv_terminate_4 ();
902   ffeexpr_terminate_4 ();
903   ffeglobal_terminate_4 ();
904   ffeimplic_terminate_4 ();
905   ffeinfo_terminate_4 ();
906   ffeintrin_terminate_4 ();
907   ffelab_terminate_4 ();
908   ffelex_terminate_4 ();
909   ffename_terminate_4 ();
910   ffesrc_terminate_4 ();
911   ffest_terminate_4 ();
912   ffestorag_terminate_4 ();
913   ffesymbol_terminate_4 ();
914   ffetarget_terminate_4 ();
915   ffetype_terminate_4 ();
916   ffewhere_terminate_4 ();
917 }
918