1627f7eb2Smrg /* Parse and display command line options.
2*4c3eb207Smrg Copyright (C) 2000-2020 Free Software Foundation, Inc.
3627f7eb2Smrg Contributed by Andy Vaught
4627f7eb2Smrg
5627f7eb2Smrg This file is part of GCC.
6627f7eb2Smrg
7627f7eb2Smrg GCC is free software; you can redistribute it and/or modify it under
8627f7eb2Smrg the terms of the GNU General Public License as published by the Free
9627f7eb2Smrg Software Foundation; either version 3, or (at your option) any later
10627f7eb2Smrg version.
11627f7eb2Smrg
12627f7eb2Smrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13627f7eb2Smrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
14627f7eb2Smrg FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15627f7eb2Smrg for more details.
16627f7eb2Smrg
17627f7eb2Smrg You should have received a copy of the GNU General Public License
18627f7eb2Smrg along with GCC; see the file COPYING3. If not see
19627f7eb2Smrg <http://www.gnu.org/licenses/>. */
20627f7eb2Smrg
21627f7eb2Smrg #include "config.h"
22627f7eb2Smrg #include "system.h"
23627f7eb2Smrg #include "coretypes.h"
24627f7eb2Smrg #include "target.h"
25627f7eb2Smrg #include "tree.h"
26627f7eb2Smrg #include "gfortran.h"
27627f7eb2Smrg #include "diagnostic.h" /* For global_dc. */
28627f7eb2Smrg #include "opts.h"
29627f7eb2Smrg #include "toplev.h" /* For save_decoded_options. */
30627f7eb2Smrg #include "cpp.h"
31627f7eb2Smrg #include "langhooks.h"
32627f7eb2Smrg
33627f7eb2Smrg gfc_option_t gfc_option;
34627f7eb2Smrg
35627f7eb2Smrg #define SET_FLAG(flag, condition, on_value, off_value) \
36627f7eb2Smrg do \
37627f7eb2Smrg { \
38627f7eb2Smrg if (condition) \
39627f7eb2Smrg flag = (on_value); \
40627f7eb2Smrg else \
41627f7eb2Smrg flag = (off_value); \
42627f7eb2Smrg } while (0)
43627f7eb2Smrg
44627f7eb2Smrg #define SET_BITFLAG2(m) m
45627f7eb2Smrg
46627f7eb2Smrg #define SET_BITFLAG(flag, condition, value) \
47627f7eb2Smrg SET_BITFLAG2 (SET_FLAG (flag, condition, (flag | (value)), (flag & ~(value))))
48627f7eb2Smrg
49627f7eb2Smrg
50627f7eb2Smrg /* Set flags that control warnings and errors for different
51627f7eb2Smrg Fortran standards to their default values. Keep in sync with
52627f7eb2Smrg libgfortran/runtime/compile_options.c (init_compile_options). */
53627f7eb2Smrg
54627f7eb2Smrg static void
set_default_std_flags(void)55627f7eb2Smrg set_default_std_flags (void)
56627f7eb2Smrg {
57627f7eb2Smrg gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
58627f7eb2Smrg | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
59627f7eb2Smrg | GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY
60627f7eb2Smrg | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS;
61627f7eb2Smrg gfc_option.warn_std = GFC_STD_F2018_DEL | GFC_STD_F95_DEL | GFC_STD_LEGACY;
62627f7eb2Smrg }
63627f7eb2Smrg
64627f7eb2Smrg /* Set (or unset) the DEC extension flags. */
65627f7eb2Smrg
66627f7eb2Smrg static void
set_dec_flags(int value)67627f7eb2Smrg set_dec_flags (int value)
68627f7eb2Smrg {
69627f7eb2Smrg /* Set (or unset) other DEC compatibility extensions. */
70627f7eb2Smrg SET_BITFLAG (flag_dollar_ok, value, value);
71627f7eb2Smrg SET_BITFLAG (flag_cray_pointer, value, value);
72627f7eb2Smrg SET_BITFLAG (flag_dec_structure, value, value);
73627f7eb2Smrg SET_BITFLAG (flag_dec_intrinsic_ints, value, value);
74627f7eb2Smrg SET_BITFLAG (flag_dec_static, value, value);
75627f7eb2Smrg SET_BITFLAG (flag_dec_math, value, value);
76627f7eb2Smrg SET_BITFLAG (flag_dec_include, value, value);
77*4c3eb207Smrg SET_BITFLAG (flag_dec_format_defaults, value, value);
78*4c3eb207Smrg SET_BITFLAG (flag_dec_blank_format_item, value, value);
79*4c3eb207Smrg SET_BITFLAG (flag_dec_char_conversions, value, value);
80627f7eb2Smrg }
81627f7eb2Smrg
82627f7eb2Smrg /* Finalize DEC flags. */
83627f7eb2Smrg
84627f7eb2Smrg static void
post_dec_flags(int value)85627f7eb2Smrg post_dec_flags (int value)
86627f7eb2Smrg {
87627f7eb2Smrg /* Don't warn for legacy code if -fdec is given; however, setting -fno-dec
88627f7eb2Smrg does not force these warnings. We make one final determination on this
89627f7eb2Smrg at the end because -std= is always set first; thus, we can avoid
90627f7eb2Smrg clobbering the user's desired standard settings in gfc_handle_option
91627f7eb2Smrg e.g. when -fdec and -fno-dec are both given. */
92627f7eb2Smrg if (value)
93627f7eb2Smrg {
94627f7eb2Smrg gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL
95627f7eb2Smrg | GFC_STD_GNU | GFC_STD_LEGACY;
96627f7eb2Smrg gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL);
97627f7eb2Smrg }
98627f7eb2Smrg }
99627f7eb2Smrg
100627f7eb2Smrg /* Enable (or disable) -finit-local-zero. */
101627f7eb2Smrg
102627f7eb2Smrg static void
set_init_local_zero(int value)103627f7eb2Smrg set_init_local_zero (int value)
104627f7eb2Smrg {
105627f7eb2Smrg gfc_option.flag_init_integer_value = 0;
106627f7eb2Smrg gfc_option.flag_init_character_value = (char)0;
107627f7eb2Smrg
108627f7eb2Smrg SET_FLAG (gfc_option.flag_init_integer, value, GFC_INIT_INTEGER_ON,
109627f7eb2Smrg GFC_INIT_INTEGER_OFF);
110627f7eb2Smrg SET_FLAG (gfc_option.flag_init_logical, value, GFC_INIT_LOGICAL_FALSE,
111627f7eb2Smrg GFC_INIT_LOGICAL_OFF);
112627f7eb2Smrg SET_FLAG (gfc_option.flag_init_character, value, GFC_INIT_CHARACTER_ON,
113627f7eb2Smrg GFC_INIT_CHARACTER_OFF);
114627f7eb2Smrg SET_FLAG (flag_init_real, value, GFC_INIT_REAL_ZERO, GFC_INIT_REAL_OFF);
115627f7eb2Smrg }
116627f7eb2Smrg
117627f7eb2Smrg /* Return language mask for Fortran options. */
118627f7eb2Smrg
119627f7eb2Smrg unsigned int
gfc_option_lang_mask(void)120627f7eb2Smrg gfc_option_lang_mask (void)
121627f7eb2Smrg {
122627f7eb2Smrg return CL_Fortran;
123627f7eb2Smrg }
124627f7eb2Smrg
125627f7eb2Smrg /* Initialize options structure OPTS. */
126627f7eb2Smrg
127627f7eb2Smrg void
gfc_init_options_struct(struct gcc_options * opts)128627f7eb2Smrg gfc_init_options_struct (struct gcc_options *opts)
129627f7eb2Smrg {
130627f7eb2Smrg opts->x_flag_errno_math = 0;
131627f7eb2Smrg opts->frontend_set_flag_errno_math = true;
132627f7eb2Smrg opts->x_flag_associative_math = -1;
133627f7eb2Smrg opts->frontend_set_flag_associative_math = true;
134627f7eb2Smrg }
135627f7eb2Smrg
136627f7eb2Smrg /* Get ready for options handling. Keep in sync with
137627f7eb2Smrg libgfortran/runtime/compile_options.c (init_compile_options). */
138627f7eb2Smrg
139627f7eb2Smrg void
gfc_init_options(unsigned int decoded_options_count,struct cl_decoded_option * decoded_options)140627f7eb2Smrg gfc_init_options (unsigned int decoded_options_count,
141627f7eb2Smrg struct cl_decoded_option *decoded_options)
142627f7eb2Smrg {
143627f7eb2Smrg gfc_source_file = NULL;
144627f7eb2Smrg gfc_option.module_dir = NULL;
145627f7eb2Smrg gfc_option.source_form = FORM_UNKNOWN;
146627f7eb2Smrg gfc_option.max_continue_fixed = 255;
147627f7eb2Smrg gfc_option.max_continue_free = 255;
148627f7eb2Smrg gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
149627f7eb2Smrg gfc_option.max_errors = 25;
150627f7eb2Smrg
151627f7eb2Smrg gfc_option.flag_preprocessed = 0;
152627f7eb2Smrg gfc_option.flag_d_lines = -1;
153627f7eb2Smrg set_init_local_zero (0);
154627f7eb2Smrg
155627f7eb2Smrg gfc_option.fpe = 0;
156627f7eb2Smrg /* All except GFC_FPE_INEXACT. */
157627f7eb2Smrg gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL
158627f7eb2Smrg | GFC_FPE_ZERO | GFC_FPE_OVERFLOW
159627f7eb2Smrg | GFC_FPE_UNDERFLOW;
160627f7eb2Smrg gfc_option.rtcheck = 0;
161627f7eb2Smrg
162627f7eb2Smrg /* ??? Wmissing-include-dirs is disabled by default in C/C++ but
163627f7eb2Smrg enabled by default in Fortran. Ideally, we should express this
164627f7eb2Smrg in .opt, but that is not supported yet. */
165*4c3eb207Smrg SET_OPTION_IF_UNSET (&global_options, &global_options_set,
166*4c3eb207Smrg cpp_warn_missing_include_dirs, 1);
167627f7eb2Smrg
168627f7eb2Smrg set_dec_flags (0);
169627f7eb2Smrg
170627f7eb2Smrg set_default_std_flags ();
171627f7eb2Smrg
172627f7eb2Smrg /* Initialize cpp-related options. */
173627f7eb2Smrg gfc_cpp_init_options (decoded_options_count, decoded_options);
174627f7eb2Smrg gfc_diagnostics_init ();
175627f7eb2Smrg }
176627f7eb2Smrg
177627f7eb2Smrg
178627f7eb2Smrg /* Determine the source form from the filename extension. We assume
179627f7eb2Smrg case insensitivity. */
180627f7eb2Smrg
181627f7eb2Smrg static gfc_source_form
form_from_filename(const char * filename)182627f7eb2Smrg form_from_filename (const char *filename)
183627f7eb2Smrg {
184627f7eb2Smrg static const struct
185627f7eb2Smrg {
186627f7eb2Smrg const char *extension;
187627f7eb2Smrg gfc_source_form form;
188627f7eb2Smrg }
189627f7eb2Smrg exttype[] =
190627f7eb2Smrg {
191627f7eb2Smrg {
192627f7eb2Smrg ".f90", FORM_FREE}
193627f7eb2Smrg ,
194627f7eb2Smrg {
195627f7eb2Smrg ".f95", FORM_FREE}
196627f7eb2Smrg ,
197627f7eb2Smrg {
198627f7eb2Smrg ".f03", FORM_FREE}
199627f7eb2Smrg ,
200627f7eb2Smrg {
201627f7eb2Smrg ".f08", FORM_FREE}
202627f7eb2Smrg ,
203627f7eb2Smrg {
204627f7eb2Smrg ".f", FORM_FIXED}
205627f7eb2Smrg ,
206627f7eb2Smrg {
207627f7eb2Smrg ".for", FORM_FIXED}
208627f7eb2Smrg ,
209627f7eb2Smrg {
210627f7eb2Smrg ".ftn", FORM_FIXED}
211627f7eb2Smrg ,
212627f7eb2Smrg {
213627f7eb2Smrg "", FORM_UNKNOWN}
214627f7eb2Smrg }; /* sentinel value */
215627f7eb2Smrg
216627f7eb2Smrg gfc_source_form f_form;
217627f7eb2Smrg const char *fileext;
218627f7eb2Smrg int i;
219627f7eb2Smrg
220627f7eb2Smrg /* Find end of file name. Note, filename is either a NULL pointer or
221627f7eb2Smrg a NUL terminated string. */
222627f7eb2Smrg i = 0;
223627f7eb2Smrg while (filename[i] != '\0')
224627f7eb2Smrg i++;
225627f7eb2Smrg
226627f7eb2Smrg /* Find last period. */
227627f7eb2Smrg while (i >= 0 && (filename[i] != '.'))
228627f7eb2Smrg i--;
229627f7eb2Smrg
230627f7eb2Smrg /* Did we see a file extension? */
231627f7eb2Smrg if (i < 0)
232627f7eb2Smrg return FORM_UNKNOWN; /* Nope */
233627f7eb2Smrg
234627f7eb2Smrg /* Get file extension and compare it to others. */
235627f7eb2Smrg fileext = &(filename[i]);
236627f7eb2Smrg
237627f7eb2Smrg i = -1;
238627f7eb2Smrg f_form = FORM_UNKNOWN;
239627f7eb2Smrg do
240627f7eb2Smrg {
241627f7eb2Smrg i++;
242627f7eb2Smrg if (strcasecmp (fileext, exttype[i].extension) == 0)
243627f7eb2Smrg {
244627f7eb2Smrg f_form = exttype[i].form;
245627f7eb2Smrg break;
246627f7eb2Smrg }
247627f7eb2Smrg }
248627f7eb2Smrg while (exttype[i].form != FORM_UNKNOWN);
249627f7eb2Smrg
250627f7eb2Smrg return f_form;
251627f7eb2Smrg }
252627f7eb2Smrg
253627f7eb2Smrg
254627f7eb2Smrg /* Finalize commandline options. */
255627f7eb2Smrg
256627f7eb2Smrg bool
gfc_post_options(const char ** pfilename)257627f7eb2Smrg gfc_post_options (const char **pfilename)
258627f7eb2Smrg {
259627f7eb2Smrg const char *filename = *pfilename, *canon_source_file = NULL;
260627f7eb2Smrg char *source_path;
261627f7eb2Smrg int i;
262627f7eb2Smrg
263627f7eb2Smrg /* Finalize DEC flags. */
264627f7eb2Smrg post_dec_flags (flag_dec);
265627f7eb2Smrg
266627f7eb2Smrg /* Excess precision other than "fast" requires front-end
267627f7eb2Smrg support. */
268*4c3eb207Smrg if (flag_excess_precision == EXCESS_PRECISION_STANDARD)
269627f7eb2Smrg sorry ("%<-fexcess-precision=standard%> for Fortran");
270*4c3eb207Smrg flag_excess_precision = EXCESS_PRECISION_FAST;
271627f7eb2Smrg
272627f7eb2Smrg /* Fortran allows associative math - but we cannot reassociate if
273627f7eb2Smrg we want traps or signed zeros. Cf. also flag_protect_parens. */
274627f7eb2Smrg if (flag_associative_math == -1)
275627f7eb2Smrg flag_associative_math = (!flag_trapping_math && !flag_signed_zeros);
276627f7eb2Smrg
277627f7eb2Smrg if (flag_protect_parens == -1)
278627f7eb2Smrg flag_protect_parens = !optimize_fast;
279627f7eb2Smrg
280627f7eb2Smrg /* -Ofast sets implies -fstack-arrays unless an explicit size is set for
281627f7eb2Smrg stack arrays. */
282627f7eb2Smrg if (flag_stack_arrays == -1 && flag_max_stack_var_size == -2)
283627f7eb2Smrg flag_stack_arrays = optimize_fast;
284627f7eb2Smrg
285627f7eb2Smrg /* By default, disable (re)allocation during assignment for -std=f95,
286627f7eb2Smrg and enable it for F2003/F2008/GNU/Legacy. */
287627f7eb2Smrg if (flag_realloc_lhs == -1)
288627f7eb2Smrg {
289627f7eb2Smrg if (gfc_option.allow_std & GFC_STD_F2003)
290627f7eb2Smrg flag_realloc_lhs = 1;
291627f7eb2Smrg else
292627f7eb2Smrg flag_realloc_lhs = 0;
293627f7eb2Smrg }
294627f7eb2Smrg
295627f7eb2Smrg /* -fbounds-check is equivalent to -fcheck=bounds */
296627f7eb2Smrg if (flag_bounds_check)
297627f7eb2Smrg gfc_option.rtcheck |= GFC_RTCHECK_BOUNDS;
298627f7eb2Smrg
299627f7eb2Smrg if (flag_compare_debug)
300627f7eb2Smrg flag_dump_fortran_original = 0;
301627f7eb2Smrg
302627f7eb2Smrg /* Make -fmax-errors visible to gfortran's diagnostic machinery. */
303627f7eb2Smrg if (global_options_set.x_flag_max_errors)
304627f7eb2Smrg gfc_option.max_errors = flag_max_errors;
305627f7eb2Smrg
306627f7eb2Smrg /* Verify the input file name. */
307627f7eb2Smrg if (!filename || strcmp (filename, "-") == 0)
308627f7eb2Smrg {
309627f7eb2Smrg filename = "";
310627f7eb2Smrg }
311627f7eb2Smrg
312627f7eb2Smrg if (gfc_option.flag_preprocessed)
313627f7eb2Smrg {
314627f7eb2Smrg /* For preprocessed files, if the first tokens are of the form # NUM.
315627f7eb2Smrg handle the directives so we know the original file name. */
316627f7eb2Smrg gfc_source_file = gfc_read_orig_filename (filename, &canon_source_file);
317627f7eb2Smrg if (gfc_source_file == NULL)
318627f7eb2Smrg gfc_source_file = filename;
319627f7eb2Smrg else
320627f7eb2Smrg *pfilename = gfc_source_file;
321627f7eb2Smrg }
322627f7eb2Smrg else
323627f7eb2Smrg gfc_source_file = filename;
324627f7eb2Smrg
325627f7eb2Smrg if (canon_source_file == NULL)
326627f7eb2Smrg canon_source_file = gfc_source_file;
327627f7eb2Smrg
328627f7eb2Smrg /* Adds the path where the source file is to the list of include files. */
329627f7eb2Smrg
330627f7eb2Smrg i = strlen (canon_source_file);
331627f7eb2Smrg while (i > 0 && !IS_DIR_SEPARATOR (canon_source_file[i]))
332627f7eb2Smrg i--;
333627f7eb2Smrg
334627f7eb2Smrg if (i != 0)
335627f7eb2Smrg {
336627f7eb2Smrg source_path = (char *) alloca (i + 1);
337627f7eb2Smrg memcpy (source_path, canon_source_file, i);
338627f7eb2Smrg source_path[i] = 0;
339627f7eb2Smrg gfc_add_include_path (source_path, true, true, true);
340627f7eb2Smrg }
341627f7eb2Smrg else
342627f7eb2Smrg gfc_add_include_path (".", true, true, true);
343627f7eb2Smrg
344627f7eb2Smrg if (canon_source_file != gfc_source_file)
345627f7eb2Smrg free (CONST_CAST (char *, canon_source_file));
346627f7eb2Smrg
347627f7eb2Smrg /* Decide which form the file will be read in as. */
348627f7eb2Smrg
349627f7eb2Smrg if (gfc_option.source_form != FORM_UNKNOWN)
350627f7eb2Smrg gfc_current_form = gfc_option.source_form;
351627f7eb2Smrg else
352627f7eb2Smrg {
353627f7eb2Smrg gfc_current_form = form_from_filename (filename);
354627f7eb2Smrg
355627f7eb2Smrg if (gfc_current_form == FORM_UNKNOWN)
356627f7eb2Smrg {
357627f7eb2Smrg gfc_current_form = FORM_FREE;
358627f7eb2Smrg main_input_filename = filename;
359627f7eb2Smrg gfc_warning_now (0, "Reading file %qs as free form",
360627f7eb2Smrg (filename[0] == '\0') ? "<stdin>" : filename);
361627f7eb2Smrg }
362627f7eb2Smrg }
363627f7eb2Smrg
364627f7eb2Smrg /* If the user specified -fd-lines-as-{code|comments} verify that we're
365627f7eb2Smrg in fixed form. */
366627f7eb2Smrg if (gfc_current_form == FORM_FREE)
367627f7eb2Smrg {
368627f7eb2Smrg if (gfc_option.flag_d_lines == 0)
369627f7eb2Smrg gfc_warning_now (0, "%<-fd-lines-as-comments%> has no effect "
370627f7eb2Smrg "in free form");
371627f7eb2Smrg else if (gfc_option.flag_d_lines == 1)
372627f7eb2Smrg gfc_warning_now (0, "%<-fd-lines-as-code%> has no effect in free form");
373627f7eb2Smrg
374627f7eb2Smrg if (warn_line_truncation == -1)
375627f7eb2Smrg warn_line_truncation = 1;
376627f7eb2Smrg
377627f7eb2Smrg /* Enable -Werror=line-truncation when -Werror and -Wno-error have
378627f7eb2Smrg not been set. */
379627f7eb2Smrg if (warn_line_truncation && !global_options_set.x_warnings_are_errors
380627f7eb2Smrg && (global_dc->classify_diagnostic[OPT_Wline_truncation] ==
381627f7eb2Smrg DK_UNSPECIFIED))
382627f7eb2Smrg diagnostic_classify_diagnostic (global_dc, OPT_Wline_truncation,
383627f7eb2Smrg DK_ERROR, UNKNOWN_LOCATION);
384627f7eb2Smrg }
385627f7eb2Smrg else
386627f7eb2Smrg {
387627f7eb2Smrg /* With -fdec, set -fd-lines-as-comments by default in fixed form. */
388627f7eb2Smrg if (flag_dec && gfc_option.flag_d_lines == -1)
389627f7eb2Smrg gfc_option.flag_d_lines = 0;
390627f7eb2Smrg
391627f7eb2Smrg if (warn_line_truncation == -1)
392627f7eb2Smrg warn_line_truncation = 0;
393627f7eb2Smrg }
394627f7eb2Smrg
395627f7eb2Smrg /* If -pedantic, warn about the use of GNU extensions. */
396627f7eb2Smrg if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0)
397627f7eb2Smrg gfc_option.warn_std |= GFC_STD_GNU;
398627f7eb2Smrg /* -std=legacy -pedantic is effectively -std=gnu. */
399627f7eb2Smrg if (pedantic && (gfc_option.allow_std & GFC_STD_LEGACY) != 0)
400627f7eb2Smrg gfc_option.warn_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_LEGACY;
401627f7eb2Smrg
402627f7eb2Smrg /* If the user didn't explicitly specify -f(no)-second-underscore we
403627f7eb2Smrg use it if we're trying to be compatible with f2c, and not
404627f7eb2Smrg otherwise. */
405627f7eb2Smrg if (flag_second_underscore == -1)
406627f7eb2Smrg flag_second_underscore = flag_f2c;
407627f7eb2Smrg
408627f7eb2Smrg if (!flag_automatic && flag_max_stack_var_size != -2
409627f7eb2Smrg && flag_max_stack_var_size != 0)
410627f7eb2Smrg gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
411627f7eb2Smrg flag_max_stack_var_size);
412627f7eb2Smrg else if (!flag_automatic && flag_recursive)
413*4c3eb207Smrg gfc_warning_now (OPT_Woverwrite_recursive, "Flag %<-fno-automatic%> "
414*4c3eb207Smrg "overwrites %<-frecursive%>");
415627f7eb2Smrg else if (!flag_automatic && flag_openmp)
416627f7eb2Smrg gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
417627f7eb2Smrg "%<-fopenmp%>");
418627f7eb2Smrg else if (flag_max_stack_var_size != -2 && flag_recursive)
419627f7eb2Smrg gfc_warning_now (0, "Flag %<-frecursive%> overwrites %<-fmax-stack-var-size=%d%>",
420627f7eb2Smrg flag_max_stack_var_size);
421627f7eb2Smrg else if (flag_max_stack_var_size != -2 && flag_openmp)
422627f7eb2Smrg gfc_warning_now (0, "Flag %<-fmax-stack-var-size=%d%> overwrites %<-frecursive%> "
423627f7eb2Smrg "implied by %<-fopenmp%>", flag_max_stack_var_size);
424627f7eb2Smrg
425627f7eb2Smrg /* Implement -frecursive as -fmax-stack-var-size=-1. */
426627f7eb2Smrg if (flag_recursive)
427627f7eb2Smrg flag_max_stack_var_size = -1;
428627f7eb2Smrg
429627f7eb2Smrg /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
430627f7eb2Smrg if (flag_max_stack_var_size == -2 && flag_openmp && flag_automatic)
431627f7eb2Smrg {
432627f7eb2Smrg flag_recursive = 1;
433627f7eb2Smrg flag_max_stack_var_size = -1;
434627f7eb2Smrg }
435627f7eb2Smrg
436627f7eb2Smrg /* Set flag_stack_arrays correctly. */
437627f7eb2Smrg if (flag_stack_arrays == -1)
438627f7eb2Smrg flag_stack_arrays = 0;
439627f7eb2Smrg
440627f7eb2Smrg /* Set default. */
441627f7eb2Smrg if (flag_max_stack_var_size == -2)
442*4c3eb207Smrg flag_max_stack_var_size = 65536;
443627f7eb2Smrg
444627f7eb2Smrg /* Implement -fno-automatic as -fmax-stack-var-size=0. */
445627f7eb2Smrg if (!flag_automatic)
446627f7eb2Smrg flag_max_stack_var_size = 0;
447627f7eb2Smrg
448627f7eb2Smrg /* If the user did not specify an inline matmul limit, inline up to the BLAS
449627f7eb2Smrg limit or up to 30 if no external BLAS is specified. */
450627f7eb2Smrg
451627f7eb2Smrg if (flag_inline_matmul_limit < 0)
452627f7eb2Smrg {
453627f7eb2Smrg if (flag_external_blas)
454627f7eb2Smrg flag_inline_matmul_limit = flag_blas_matmul_limit;
455627f7eb2Smrg else
456627f7eb2Smrg flag_inline_matmul_limit = 30;
457627f7eb2Smrg }
458627f7eb2Smrg
459627f7eb2Smrg /* Optimization implies front end optimization, unless the user
460627f7eb2Smrg specified it directly. */
461627f7eb2Smrg
462627f7eb2Smrg if (flag_frontend_optimize == -1)
463627f7eb2Smrg flag_frontend_optimize = optimize && !optimize_debug;
464627f7eb2Smrg
465627f7eb2Smrg /* Same for front end loop interchange. */
466627f7eb2Smrg
467627f7eb2Smrg if (flag_frontend_loop_interchange == -1)
468627f7eb2Smrg flag_frontend_loop_interchange = optimize;
469627f7eb2Smrg
470*4c3eb207Smrg /* Do inline packing by default if optimizing, but not if
471*4c3eb207Smrg optimizing for size. */
472*4c3eb207Smrg if (flag_inline_arg_packing == -1)
473*4c3eb207Smrg flag_inline_arg_packing = optimize && !optimize_size;
474*4c3eb207Smrg
475627f7eb2Smrg if (flag_max_array_constructor < 65535)
476627f7eb2Smrg flag_max_array_constructor = 65535;
477627f7eb2Smrg
478627f7eb2Smrg if (flag_fixed_line_length != 0 && flag_fixed_line_length < 7)
479627f7eb2Smrg gfc_fatal_error ("Fixed line length must be at least seven");
480627f7eb2Smrg
481627f7eb2Smrg if (flag_free_line_length != 0 && flag_free_line_length < 4)
482627f7eb2Smrg gfc_fatal_error ("Free line length must be at least three");
483627f7eb2Smrg
484627f7eb2Smrg if (flag_max_subrecord_length > MAX_SUBRECORD_LENGTH)
485627f7eb2Smrg gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
486627f7eb2Smrg MAX_SUBRECORD_LENGTH);
487627f7eb2Smrg
488627f7eb2Smrg gfc_cpp_post_options ();
489627f7eb2Smrg
490627f7eb2Smrg if (gfc_option.allow_std & GFC_STD_F2008)
491627f7eb2Smrg lang_hooks.name = "GNU Fortran2008";
492627f7eb2Smrg else if (gfc_option.allow_std & GFC_STD_F2003)
493627f7eb2Smrg lang_hooks.name = "GNU Fortran2003";
494627f7eb2Smrg
495627f7eb2Smrg return gfc_cpp_preprocess_only ();
496627f7eb2Smrg }
497627f7eb2Smrg
498627f7eb2Smrg
499627f7eb2Smrg static void
gfc_handle_module_path_options(const char * arg)500627f7eb2Smrg gfc_handle_module_path_options (const char *arg)
501627f7eb2Smrg {
502627f7eb2Smrg
503627f7eb2Smrg if (gfc_option.module_dir != NULL)
504627f7eb2Smrg gfc_fatal_error ("gfortran: Only one %<-J%> option allowed");
505627f7eb2Smrg
506627f7eb2Smrg gfc_option.module_dir = XCNEWVEC (char, strlen (arg) + 2);
507627f7eb2Smrg strcpy (gfc_option.module_dir, arg);
508627f7eb2Smrg
509627f7eb2Smrg gfc_add_include_path (gfc_option.module_dir, true, false, true);
510627f7eb2Smrg
511627f7eb2Smrg strcat (gfc_option.module_dir, "/");
512627f7eb2Smrg }
513627f7eb2Smrg
514627f7eb2Smrg
515627f7eb2Smrg /* Handle options -ffpe-trap= and -ffpe-summary=. */
516627f7eb2Smrg
517627f7eb2Smrg static void
gfc_handle_fpe_option(const char * arg,bool trap)518627f7eb2Smrg gfc_handle_fpe_option (const char *arg, bool trap)
519627f7eb2Smrg {
520627f7eb2Smrg int result, pos = 0, n;
521627f7eb2Smrg /* precision is a backwards compatibility alias for inexact. */
522627f7eb2Smrg static const char * const exception[] = { "invalid", "denormal", "zero",
523627f7eb2Smrg "overflow", "underflow",
524627f7eb2Smrg "inexact", "precision", NULL };
525627f7eb2Smrg static const int opt_exception[] = { GFC_FPE_INVALID, GFC_FPE_DENORMAL,
526627f7eb2Smrg GFC_FPE_ZERO, GFC_FPE_OVERFLOW,
527627f7eb2Smrg GFC_FPE_UNDERFLOW, GFC_FPE_INEXACT,
528627f7eb2Smrg GFC_FPE_INEXACT,
529627f7eb2Smrg 0 };
530627f7eb2Smrg
531627f7eb2Smrg /* As the default for -ffpe-summary= is nonzero, set it to 0. */
532627f7eb2Smrg if (!trap)
533627f7eb2Smrg gfc_option.fpe_summary = 0;
534627f7eb2Smrg
535627f7eb2Smrg while (*arg)
536627f7eb2Smrg {
537627f7eb2Smrg while (*arg == ',')
538627f7eb2Smrg arg++;
539627f7eb2Smrg
540627f7eb2Smrg while (arg[pos] && arg[pos] != ',')
541627f7eb2Smrg pos++;
542627f7eb2Smrg
543627f7eb2Smrg result = 0;
544627f7eb2Smrg if (!trap && strncmp ("none", arg, pos) == 0)
545627f7eb2Smrg {
546627f7eb2Smrg gfc_option.fpe_summary = 0;
547627f7eb2Smrg arg += pos;
548627f7eb2Smrg pos = 0;
549627f7eb2Smrg continue;
550627f7eb2Smrg }
551627f7eb2Smrg else if (!trap && strncmp ("all", arg, pos) == 0)
552627f7eb2Smrg {
553627f7eb2Smrg gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL
554627f7eb2Smrg | GFC_FPE_ZERO | GFC_FPE_OVERFLOW
555627f7eb2Smrg | GFC_FPE_UNDERFLOW | GFC_FPE_INEXACT;
556627f7eb2Smrg arg += pos;
557627f7eb2Smrg pos = 0;
558627f7eb2Smrg continue;
559627f7eb2Smrg }
560627f7eb2Smrg else
561627f7eb2Smrg for (n = 0; exception[n] != NULL; n++)
562627f7eb2Smrg {
563627f7eb2Smrg if (exception[n] && strncmp (exception[n], arg, pos) == 0)
564627f7eb2Smrg {
565627f7eb2Smrg if (trap)
566627f7eb2Smrg gfc_option.fpe |= opt_exception[n];
567627f7eb2Smrg else
568627f7eb2Smrg gfc_option.fpe_summary |= opt_exception[n];
569627f7eb2Smrg arg += pos;
570627f7eb2Smrg pos = 0;
571627f7eb2Smrg result = 1;
572627f7eb2Smrg break;
573627f7eb2Smrg }
574627f7eb2Smrg }
575627f7eb2Smrg if (!result && !trap)
576627f7eb2Smrg gfc_fatal_error ("Argument to %<-ffpe-trap%> is not valid: %s", arg);
577627f7eb2Smrg else if (!result)
578627f7eb2Smrg gfc_fatal_error ("Argument to %<-ffpe-summary%> is not valid: %s", arg);
579627f7eb2Smrg
580627f7eb2Smrg }
581627f7eb2Smrg }
582627f7eb2Smrg
583627f7eb2Smrg
584627f7eb2Smrg static void
gfc_handle_runtime_check_option(const char * arg)585627f7eb2Smrg gfc_handle_runtime_check_option (const char *arg)
586627f7eb2Smrg {
587627f7eb2Smrg int result, pos = 0, n;
588627f7eb2Smrg static const char * const optname[] = { "all", "bounds", "array-temps",
589627f7eb2Smrg "recursion", "do", "pointer",
590*4c3eb207Smrg "mem", "bits", NULL };
591627f7eb2Smrg static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS,
592627f7eb2Smrg GFC_RTCHECK_ARRAY_TEMPS,
593627f7eb2Smrg GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO,
594627f7eb2Smrg GFC_RTCHECK_POINTER, GFC_RTCHECK_MEM,
595*4c3eb207Smrg GFC_RTCHECK_BITS, 0 };
596627f7eb2Smrg
597627f7eb2Smrg while (*arg)
598627f7eb2Smrg {
599627f7eb2Smrg while (*arg == ',')
600627f7eb2Smrg arg++;
601627f7eb2Smrg
602627f7eb2Smrg while (arg[pos] && arg[pos] != ',')
603627f7eb2Smrg pos++;
604627f7eb2Smrg
605627f7eb2Smrg result = 0;
606627f7eb2Smrg for (n = 0; optname[n] != NULL; n++)
607627f7eb2Smrg {
608627f7eb2Smrg if (optname[n] && strncmp (optname[n], arg, pos) == 0)
609627f7eb2Smrg {
610627f7eb2Smrg gfc_option.rtcheck |= optmask[n];
611627f7eb2Smrg arg += pos;
612627f7eb2Smrg pos = 0;
613627f7eb2Smrg result = 1;
614627f7eb2Smrg break;
615627f7eb2Smrg }
616627f7eb2Smrg else if (optname[n] && pos > 3 && gfc_str_startswith (arg, "no-")
617627f7eb2Smrg && strncmp (optname[n], arg+3, pos-3) == 0)
618627f7eb2Smrg {
619627f7eb2Smrg gfc_option.rtcheck &= ~optmask[n];
620627f7eb2Smrg arg += pos;
621627f7eb2Smrg pos = 0;
622627f7eb2Smrg result = 1;
623627f7eb2Smrg break;
624627f7eb2Smrg }
625627f7eb2Smrg }
626627f7eb2Smrg if (!result)
627627f7eb2Smrg gfc_fatal_error ("Argument to %<-fcheck%> is not valid: %s", arg);
628627f7eb2Smrg }
629627f7eb2Smrg }
630627f7eb2Smrg
631627f7eb2Smrg
632627f7eb2Smrg /* Handle command-line options. Returns 0 if unrecognized, 1 if
633627f7eb2Smrg recognized and handled. */
634627f7eb2Smrg
635627f7eb2Smrg bool
gfc_handle_option(size_t scode,const char * arg,HOST_WIDE_INT value,int kind ATTRIBUTE_UNUSED,location_t loc ATTRIBUTE_UNUSED,const struct cl_option_handlers * handlers ATTRIBUTE_UNUSED)636627f7eb2Smrg gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
637627f7eb2Smrg int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED,
638627f7eb2Smrg const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
639627f7eb2Smrg {
640627f7eb2Smrg bool result = true;
641627f7eb2Smrg enum opt_code code = (enum opt_code) scode;
642627f7eb2Smrg
643627f7eb2Smrg if (gfc_cpp_handle_option (scode, arg, value) == 1)
644627f7eb2Smrg return true;
645627f7eb2Smrg
646627f7eb2Smrg switch (code)
647627f7eb2Smrg {
648627f7eb2Smrg default:
649627f7eb2Smrg if (cl_options[code].flags & gfc_option_lang_mask ())
650627f7eb2Smrg break;
651627f7eb2Smrg result = false;
652627f7eb2Smrg break;
653627f7eb2Smrg
654627f7eb2Smrg case OPT_fcheck_array_temporaries:
655627f7eb2Smrg SET_BITFLAG (gfc_option.rtcheck, value, GFC_RTCHECK_ARRAY_TEMPS);
656627f7eb2Smrg break;
657627f7eb2Smrg
658627f7eb2Smrg case OPT_fd_lines_as_code:
659627f7eb2Smrg gfc_option.flag_d_lines = 1;
660627f7eb2Smrg break;
661627f7eb2Smrg
662627f7eb2Smrg case OPT_fd_lines_as_comments:
663627f7eb2Smrg gfc_option.flag_d_lines = 0;
664627f7eb2Smrg break;
665627f7eb2Smrg
666627f7eb2Smrg case OPT_ffixed_form:
667627f7eb2Smrg gfc_option.source_form = FORM_FIXED;
668627f7eb2Smrg break;
669627f7eb2Smrg
670627f7eb2Smrg case OPT_ffree_form:
671627f7eb2Smrg gfc_option.source_form = FORM_FREE;
672627f7eb2Smrg break;
673627f7eb2Smrg
674627f7eb2Smrg case OPT_static_libgfortran:
675627f7eb2Smrg #ifndef HAVE_LD_STATIC_DYNAMIC
676627f7eb2Smrg gfc_fatal_error ("%<-static-libgfortran%> is not supported in this "
677627f7eb2Smrg "configuration");
678627f7eb2Smrg #endif
679627f7eb2Smrg break;
680627f7eb2Smrg
681627f7eb2Smrg case OPT_fintrinsic_modules_path:
682627f7eb2Smrg case OPT_fintrinsic_modules_path_:
683627f7eb2Smrg
684627f7eb2Smrg /* This is needed because omp_lib.h is in a directory together
685627f7eb2Smrg with intrinsic modules. Do no warn because during testing
686627f7eb2Smrg without an installed compiler, we would get lots of bogus
687627f7eb2Smrg warnings for a missing include directory. */
688627f7eb2Smrg gfc_add_include_path (arg, false, false, false);
689627f7eb2Smrg
690627f7eb2Smrg gfc_add_intrinsic_modules_path (arg);
691627f7eb2Smrg break;
692627f7eb2Smrg
693627f7eb2Smrg case OPT_fpreprocessed:
694627f7eb2Smrg gfc_option.flag_preprocessed = value;
695627f7eb2Smrg break;
696627f7eb2Smrg
697627f7eb2Smrg case OPT_fmax_identifier_length_:
698627f7eb2Smrg if (value > GFC_MAX_SYMBOL_LEN)
699627f7eb2Smrg gfc_fatal_error ("Maximum supported identifier length is %d",
700627f7eb2Smrg GFC_MAX_SYMBOL_LEN);
701627f7eb2Smrg gfc_option.max_identifier_length = value;
702627f7eb2Smrg break;
703627f7eb2Smrg
704627f7eb2Smrg case OPT_finit_local_zero:
705627f7eb2Smrg set_init_local_zero (value);
706627f7eb2Smrg break;
707627f7eb2Smrg
708627f7eb2Smrg case OPT_finit_logical_:
709627f7eb2Smrg if (!strcasecmp (arg, "false"))
710627f7eb2Smrg gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
711627f7eb2Smrg else if (!strcasecmp (arg, "true"))
712627f7eb2Smrg gfc_option.flag_init_logical = GFC_INIT_LOGICAL_TRUE;
713627f7eb2Smrg else
714627f7eb2Smrg gfc_fatal_error ("Unrecognized option to %<-finit-logical%>: %s",
715627f7eb2Smrg arg);
716627f7eb2Smrg break;
717627f7eb2Smrg
718627f7eb2Smrg case OPT_finit_integer_:
719627f7eb2Smrg gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
720627f7eb2Smrg gfc_option.flag_init_integer_value = strtol (arg, NULL, 10);
721627f7eb2Smrg break;
722627f7eb2Smrg
723627f7eb2Smrg case OPT_finit_character_:
724627f7eb2Smrg if (value >= 0 && value <= 127)
725627f7eb2Smrg {
726627f7eb2Smrg gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
727627f7eb2Smrg gfc_option.flag_init_character_value = (char)value;
728627f7eb2Smrg }
729627f7eb2Smrg else
730627f7eb2Smrg gfc_fatal_error ("The value of n in %<-finit-character=n%> must be "
731627f7eb2Smrg "between 0 and 127");
732627f7eb2Smrg break;
733627f7eb2Smrg
734627f7eb2Smrg case OPT_I:
735627f7eb2Smrg gfc_add_include_path (arg, true, false, true);
736627f7eb2Smrg break;
737627f7eb2Smrg
738627f7eb2Smrg case OPT_J:
739627f7eb2Smrg gfc_handle_module_path_options (arg);
740627f7eb2Smrg break;
741627f7eb2Smrg
742627f7eb2Smrg case OPT_ffpe_trap_:
743627f7eb2Smrg gfc_handle_fpe_option (arg, true);
744627f7eb2Smrg break;
745627f7eb2Smrg
746627f7eb2Smrg case OPT_ffpe_summary_:
747627f7eb2Smrg gfc_handle_fpe_option (arg, false);
748627f7eb2Smrg break;
749627f7eb2Smrg
750627f7eb2Smrg case OPT_std_f95:
751627f7eb2Smrg gfc_option.allow_std = GFC_STD_OPT_F95;
752627f7eb2Smrg gfc_option.warn_std = GFC_STD_F95_OBS;
753627f7eb2Smrg gfc_option.max_continue_fixed = 19;
754627f7eb2Smrg gfc_option.max_continue_free = 39;
755627f7eb2Smrg gfc_option.max_identifier_length = 31;
756627f7eb2Smrg warn_ampersand = 1;
757627f7eb2Smrg warn_tabs = 1;
758627f7eb2Smrg break;
759627f7eb2Smrg
760627f7eb2Smrg case OPT_std_f2003:
761627f7eb2Smrg gfc_option.allow_std = GFC_STD_OPT_F03;
762627f7eb2Smrg gfc_option.warn_std = GFC_STD_F95_OBS;
763627f7eb2Smrg gfc_option.max_identifier_length = 63;
764627f7eb2Smrg warn_ampersand = 1;
765627f7eb2Smrg warn_tabs = 1;
766627f7eb2Smrg break;
767627f7eb2Smrg
768627f7eb2Smrg case OPT_std_f2008:
769627f7eb2Smrg gfc_option.allow_std = GFC_STD_OPT_F08;
770627f7eb2Smrg gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
771627f7eb2Smrg gfc_option.max_identifier_length = 63;
772627f7eb2Smrg warn_ampersand = 1;
773627f7eb2Smrg warn_tabs = 1;
774627f7eb2Smrg break;
775627f7eb2Smrg
776627f7eb2Smrg case OPT_std_f2008ts:
777627f7eb2Smrg case OPT_std_f2018:
778627f7eb2Smrg gfc_option.allow_std = GFC_STD_OPT_F18;
779627f7eb2Smrg gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS
780627f7eb2Smrg | GFC_STD_F2018_OBS;
781627f7eb2Smrg gfc_option.max_identifier_length = 63;
782627f7eb2Smrg warn_ampersand = 1;
783627f7eb2Smrg warn_tabs = 1;
784627f7eb2Smrg break;
785627f7eb2Smrg
786627f7eb2Smrg case OPT_std_gnu:
787627f7eb2Smrg set_default_std_flags ();
788627f7eb2Smrg break;
789627f7eb2Smrg
790627f7eb2Smrg case OPT_std_legacy:
791627f7eb2Smrg set_default_std_flags ();
792627f7eb2Smrg gfc_option.warn_std = 0;
793627f7eb2Smrg break;
794627f7eb2Smrg
795627f7eb2Smrg case OPT_fshort_enums:
796627f7eb2Smrg /* Handled in language-independent code. */
797627f7eb2Smrg break;
798627f7eb2Smrg
799627f7eb2Smrg case OPT_fcheck_:
800627f7eb2Smrg gfc_handle_runtime_check_option (arg);
801627f7eb2Smrg break;
802627f7eb2Smrg
803627f7eb2Smrg case OPT_fdec:
804627f7eb2Smrg /* Set (or unset) the DEC extension flags. */
805627f7eb2Smrg set_dec_flags (value);
806627f7eb2Smrg break;
807627f7eb2Smrg }
808627f7eb2Smrg
809627f7eb2Smrg Fortran_handle_option_auto (&global_options, &global_options_set,
810627f7eb2Smrg scode, arg, value,
811627f7eb2Smrg gfc_option_lang_mask (), kind,
812627f7eb2Smrg loc, handlers, global_dc);
813627f7eb2Smrg return result;
814627f7eb2Smrg }
815627f7eb2Smrg
816627f7eb2Smrg
817627f7eb2Smrg /* Return a string with the options passed to the compiler; used for
818627f7eb2Smrg Fortran's compiler_options() intrinsic. */
819627f7eb2Smrg
820627f7eb2Smrg char *
gfc_get_option_string(void)821627f7eb2Smrg gfc_get_option_string (void)
822627f7eb2Smrg {
823627f7eb2Smrg unsigned j;
824627f7eb2Smrg size_t len, pos;
825627f7eb2Smrg char *result;
826627f7eb2Smrg
827627f7eb2Smrg /* Allocate and return a one-character string with '\0'. */
828627f7eb2Smrg if (!save_decoded_options_count)
829627f7eb2Smrg return XCNEWVEC (char, 1);
830627f7eb2Smrg
831627f7eb2Smrg /* Determine required string length. */
832627f7eb2Smrg
833627f7eb2Smrg len = 0;
834627f7eb2Smrg for (j = 1; j < save_decoded_options_count; j++)
835627f7eb2Smrg {
836627f7eb2Smrg switch (save_decoded_options[j].opt_index)
837627f7eb2Smrg {
838627f7eb2Smrg case OPT_o:
839627f7eb2Smrg case OPT_d:
840627f7eb2Smrg case OPT_dumpbase:
841627f7eb2Smrg case OPT_dumpdir:
842627f7eb2Smrg case OPT_auxbase:
843627f7eb2Smrg case OPT_quiet:
844627f7eb2Smrg case OPT_version:
845627f7eb2Smrg case OPT_fintrinsic_modules_path:
846627f7eb2Smrg case OPT_fintrinsic_modules_path_:
847627f7eb2Smrg /* Ignore these. */
848627f7eb2Smrg break;
849627f7eb2Smrg default:
850627f7eb2Smrg /* Ignore file names. */
851627f7eb2Smrg if (save_decoded_options[j].orig_option_with_args_text[0] == '-')
852627f7eb2Smrg len += 1
853627f7eb2Smrg + strlen (save_decoded_options[j].orig_option_with_args_text);
854627f7eb2Smrg }
855627f7eb2Smrg }
856627f7eb2Smrg
857627f7eb2Smrg result = XCNEWVEC (char, len);
858627f7eb2Smrg
859627f7eb2Smrg pos = 0;
860627f7eb2Smrg for (j = 1; j < save_decoded_options_count; j++)
861627f7eb2Smrg {
862627f7eb2Smrg switch (save_decoded_options[j].opt_index)
863627f7eb2Smrg {
864627f7eb2Smrg case OPT_o:
865627f7eb2Smrg case OPT_d:
866627f7eb2Smrg case OPT_dumpbase:
867627f7eb2Smrg case OPT_dumpdir:
868627f7eb2Smrg case OPT_auxbase:
869627f7eb2Smrg case OPT_quiet:
870627f7eb2Smrg case OPT_version:
871627f7eb2Smrg case OPT_fintrinsic_modules_path:
872627f7eb2Smrg case OPT_fintrinsic_modules_path_:
873627f7eb2Smrg /* Ignore these. */
874627f7eb2Smrg continue;
875627f7eb2Smrg
876627f7eb2Smrg case OPT_cpp_:
877627f7eb2Smrg /* Use "-cpp" rather than "-cpp=<temporary file>". */
878627f7eb2Smrg len = 4;
879627f7eb2Smrg break;
880627f7eb2Smrg
881627f7eb2Smrg default:
882627f7eb2Smrg /* Ignore file names. */
883627f7eb2Smrg if (save_decoded_options[j].orig_option_with_args_text[0] != '-')
884627f7eb2Smrg continue;
885627f7eb2Smrg
886627f7eb2Smrg len = strlen (save_decoded_options[j].orig_option_with_args_text);
887627f7eb2Smrg }
888627f7eb2Smrg
889627f7eb2Smrg memcpy (&result[pos], save_decoded_options[j].orig_option_with_args_text, len);
890627f7eb2Smrg pos += len;
891627f7eb2Smrg result[pos++] = ' ';
892627f7eb2Smrg }
893627f7eb2Smrg
894627f7eb2Smrg result[--pos] = '\0';
895627f7eb2Smrg return result;
896627f7eb2Smrg }
897627f7eb2Smrg
898627f7eb2Smrg #undef SET_BITFLAG
899627f7eb2Smrg #undef SET_BITFLAG2
900627f7eb2Smrg #undef SET_FLAG
901