2015-12-18 Ville Voutilainen <ville.voutilainen@gmail.com>
[official-gcc.git] / gcc / fortran / options.c
blobd91b0f68cc3f8ee6f4398eeefa7d40ea025a6999
1 /* Parse and display command line options.
2 Copyright (C) 2000-2015 Free Software Foundation, Inc.
3 Contributed by Andy Vaught
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "target.h"
25 #include "tree.h"
26 #include "gfortran.h"
27 #include "diagnostic.h" /* For global_dc. */
28 #include "opts.h"
29 #include "toplev.h" /* For save_decoded_options. */
30 #include "cpp.h"
31 #include "langhooks.h"
33 gfc_option_t gfc_option;
36 /* Set flags that control warnings and errors for different
37 Fortran standards to their default values. Keep in sync with
38 libgfortran/runtime/compile_options.c (init_compile_options). */
40 static void
41 set_default_std_flags (void)
43 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
44 | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
45 | GFC_STD_F2008_OBS | GFC_STD_F2008_TS | GFC_STD_GNU | GFC_STD_LEGACY;
46 gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
50 /* Return language mask for Fortran options. */
52 unsigned int
53 gfc_option_lang_mask (void)
55 return CL_Fortran;
58 /* Initialize options structure OPTS. */
60 void
61 gfc_init_options_struct (struct gcc_options *opts)
63 opts->x_flag_errno_math = 0;
64 opts->frontend_set_flag_errno_math = true;
65 opts->x_flag_associative_math = -1;
66 opts->frontend_set_flag_associative_math = true;
69 /* Get ready for options handling. Keep in sync with
70 libgfortran/runtime/compile_options.c (init_compile_options). */
72 void
73 gfc_init_options (unsigned int decoded_options_count,
74 struct cl_decoded_option *decoded_options)
76 gfc_source_file = NULL;
77 gfc_option.module_dir = NULL;
78 gfc_option.source_form = FORM_UNKNOWN;
79 gfc_option.max_continue_fixed = 255;
80 gfc_option.max_continue_free = 255;
81 gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
82 gfc_option.max_errors = 25;
84 gfc_option.flag_preprocessed = 0;
85 gfc_option.flag_d_lines = -1;
86 gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF;
87 gfc_option.flag_init_integer_value = 0;
88 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_OFF;
89 gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF;
90 gfc_option.flag_init_character_value = (char)0;
92 gfc_option.fpe = 0;
93 /* All except GFC_FPE_INEXACT. */
94 gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL
95 | GFC_FPE_ZERO | GFC_FPE_OVERFLOW
96 | GFC_FPE_UNDERFLOW;
97 gfc_option.rtcheck = 0;
99 /* ??? Wmissing-include-dirs is disabled by default in C/C++ but
100 enabled by default in Fortran. Ideally, we should express this
101 in .opt, but that is not supported yet. */
102 if (!global_options_set.x_cpp_warn_missing_include_dirs)
103 global_options.x_cpp_warn_missing_include_dirs = 1;
105 set_default_std_flags ();
107 /* Initialize cpp-related options. */
108 gfc_cpp_init_options (decoded_options_count, decoded_options);
109 gfc_diagnostics_init ();
113 /* Determine the source form from the filename extension. We assume
114 case insensitivity. */
116 static gfc_source_form
117 form_from_filename (const char *filename)
119 static const struct
121 const char *extension;
122 gfc_source_form form;
124 exttype[] =
127 ".f90", FORM_FREE}
130 ".f95", FORM_FREE}
133 ".f03", FORM_FREE}
136 ".f08", FORM_FREE}
139 ".f", FORM_FIXED}
142 ".for", FORM_FIXED}
145 ".ftn", FORM_FIXED}
148 "", FORM_UNKNOWN}
149 }; /* sentinel value */
151 gfc_source_form f_form;
152 const char *fileext;
153 int i;
155 /* Find end of file name. Note, filename is either a NULL pointer or
156 a NUL terminated string. */
157 i = 0;
158 while (filename[i] != '\0')
159 i++;
161 /* Find last period. */
162 while (i >= 0 && (filename[i] != '.'))
163 i--;
165 /* Did we see a file extension? */
166 if (i < 0)
167 return FORM_UNKNOWN; /* Nope */
169 /* Get file extension and compare it to others. */
170 fileext = &(filename[i]);
172 i = -1;
173 f_form = FORM_UNKNOWN;
176 i++;
177 if (strcasecmp (fileext, exttype[i].extension) == 0)
179 f_form = exttype[i].form;
180 break;
183 while (exttype[i].form != FORM_UNKNOWN);
185 return f_form;
189 /* Finalize commandline options. */
191 bool
192 gfc_post_options (const char **pfilename)
194 const char *filename = *pfilename, *canon_source_file = NULL;
195 char *source_path;
196 int i;
198 /* Excess precision other than "fast" requires front-end
199 support. */
200 if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD
201 && TARGET_FLT_EVAL_METHOD_NON_DEFAULT)
202 sorry ("-fexcess-precision=standard for Fortran");
203 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
205 /* Fortran allows associative math - but we cannot reassociate if
206 we want traps or signed zeros. Cf. also flag_protect_parens. */
207 if (flag_associative_math == -1)
208 flag_associative_math = (!flag_trapping_math && !flag_signed_zeros);
210 if (flag_protect_parens == -1)
211 flag_protect_parens = !optimize_fast;
213 if (flag_stack_arrays == -1)
214 flag_stack_arrays = optimize_fast;
216 /* By default, disable (re)allocation during assignment for -std=f95,
217 and enable it for F2003/F2008/GNU/Legacy. */
218 if (flag_realloc_lhs == -1)
220 if (gfc_option.allow_std & GFC_STD_F2003)
221 flag_realloc_lhs = 1;
222 else
223 flag_realloc_lhs = 0;
226 /* -fbounds-check is equivalent to -fcheck=bounds */
227 if (flag_bounds_check)
228 gfc_option.rtcheck |= GFC_RTCHECK_BOUNDS;
230 if (flag_compare_debug)
231 flag_dump_fortran_original = 0;
233 /* Make -fmax-errors visible to gfortran's diagnostic machinery. */
234 if (global_options_set.x_flag_max_errors)
235 gfc_option.max_errors = flag_max_errors;
237 /* Verify the input file name. */
238 if (!filename || strcmp (filename, "-") == 0)
240 filename = "";
243 if (gfc_option.flag_preprocessed)
245 /* For preprocessed files, if the first tokens are of the form # NUM.
246 handle the directives so we know the original file name. */
247 gfc_source_file = gfc_read_orig_filename (filename, &canon_source_file);
248 if (gfc_source_file == NULL)
249 gfc_source_file = filename;
250 else
251 *pfilename = gfc_source_file;
253 else
254 gfc_source_file = filename;
256 if (canon_source_file == NULL)
257 canon_source_file = gfc_source_file;
259 /* Adds the path where the source file is to the list of include files. */
261 i = strlen (canon_source_file);
262 while (i > 0 && !IS_DIR_SEPARATOR (canon_source_file[i]))
263 i--;
265 if (i != 0)
267 source_path = (char *) alloca (i + 1);
268 memcpy (source_path, canon_source_file, i);
269 source_path[i] = 0;
270 gfc_add_include_path (source_path, true, true, true);
272 else
273 gfc_add_include_path (".", true, true, true);
275 if (canon_source_file != gfc_source_file)
276 free (CONST_CAST (char *, canon_source_file));
278 /* Decide which form the file will be read in as. */
280 if (gfc_option.source_form != FORM_UNKNOWN)
281 gfc_current_form = gfc_option.source_form;
282 else
284 gfc_current_form = form_from_filename (filename);
286 if (gfc_current_form == FORM_UNKNOWN)
288 gfc_current_form = FORM_FREE;
289 gfc_warning_now (0, "Reading file %qs as free form",
290 (filename[0] == '\0') ? "<stdin>" : filename);
294 /* If the user specified -fd-lines-as-{code|comments} verify that we're
295 in fixed form. */
296 if (gfc_current_form == FORM_FREE)
298 if (gfc_option.flag_d_lines == 0)
299 gfc_warning_now (0, "%<-fd-lines-as-comments%> has no effect "
300 "in free form");
301 else if (gfc_option.flag_d_lines == 1)
302 gfc_warning_now (0, "%<-fd-lines-as-code%> has no effect in free form");
304 if (warn_line_truncation == -1)
305 warn_line_truncation = 1;
307 /* Enable -Werror=line-truncation when -Werror and -Wno-error have
308 not been set. */
309 if (warn_line_truncation && !global_options_set.x_warnings_are_errors
310 && (global_dc->classify_diagnostic[OPT_Wline_truncation] ==
311 DK_UNSPECIFIED))
312 diagnostic_classify_diagnostic (global_dc, OPT_Wline_truncation,
313 DK_ERROR, UNKNOWN_LOCATION);
315 else if (warn_line_truncation == -1)
316 warn_line_truncation = 0;
318 /* If -pedantic, warn about the use of GNU extensions. */
319 if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0)
320 gfc_option.warn_std |= GFC_STD_GNU;
321 /* -std=legacy -pedantic is effectively -std=gnu. */
322 if (pedantic && (gfc_option.allow_std & GFC_STD_LEGACY) != 0)
323 gfc_option.warn_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_LEGACY;
325 /* If the user didn't explicitly specify -f(no)-second-underscore we
326 use it if we're trying to be compatible with f2c, and not
327 otherwise. */
328 if (flag_second_underscore == -1)
329 flag_second_underscore = flag_f2c;
331 if (!flag_automatic && flag_max_stack_var_size != -2
332 && flag_max_stack_var_size != 0)
333 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
334 flag_max_stack_var_size);
335 else if (!flag_automatic && flag_recursive)
336 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%>");
337 else if (!flag_automatic && flag_openmp)
338 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
339 "%<-fopenmp%>");
340 else if (flag_max_stack_var_size != -2 && flag_recursive)
341 gfc_warning_now (0, "Flag %<-frecursive%> overwrites %<-fmax-stack-var-size=%d%>",
342 flag_max_stack_var_size);
343 else if (flag_max_stack_var_size != -2 && flag_openmp)
344 gfc_warning_now (0, "Flag %<-fmax-stack-var-size=%d%> overwrites %<-frecursive%> "
345 "implied by %<-fopenmp%>", flag_max_stack_var_size);
347 /* Implement -frecursive as -fmax-stack-var-size=-1. */
348 if (flag_recursive)
349 flag_max_stack_var_size = -1;
351 /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
352 if (flag_max_stack_var_size == -2 && flag_openmp && flag_automatic)
354 flag_recursive = 1;
355 flag_max_stack_var_size = -1;
358 /* Set default. */
359 if (flag_max_stack_var_size == -2)
360 flag_max_stack_var_size = 32768;
362 /* Implement -fno-automatic as -fmax-stack-var-size=0. */
363 if (!flag_automatic)
364 flag_max_stack_var_size = 0;
366 /* If we call BLAS directly, only inline up to the BLAS limit. */
368 if (flag_external_blas && flag_inline_matmul_limit < 0)
369 flag_inline_matmul_limit = flag_blas_matmul_limit;
371 /* Optimization implies front end optimization, unless the user
372 specified it directly. */
374 if (flag_frontend_optimize == -1)
375 flag_frontend_optimize = optimize;
377 if (flag_max_array_constructor < 65535)
378 flag_max_array_constructor = 65535;
380 if (flag_fixed_line_length != 0 && flag_fixed_line_length < 7)
381 gfc_fatal_error ("Fixed line length must be at least seven");
383 if (flag_free_line_length != 0 && flag_free_line_length < 4)
384 gfc_fatal_error ("Free line length must be at least three");
386 if (flag_max_subrecord_length > MAX_SUBRECORD_LENGTH)
387 gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
388 MAX_SUBRECORD_LENGTH);
390 gfc_cpp_post_options ();
392 if (gfc_option.allow_std & GFC_STD_F2008)
393 lang_hooks.name = "GNU Fortran2008";
394 else if (gfc_option.allow_std & GFC_STD_F2003)
395 lang_hooks.name = "GNU Fortran2003";
397 return gfc_cpp_preprocess_only ();
401 static void
402 gfc_handle_module_path_options (const char *arg)
405 if (gfc_option.module_dir != NULL)
406 gfc_fatal_error ("gfortran: Only one %<-J%> option allowed");
408 gfc_option.module_dir = XCNEWVEC (char, strlen (arg) + 2);
409 strcpy (gfc_option.module_dir, arg);
411 gfc_add_include_path (gfc_option.module_dir, true, false, true);
413 strcat (gfc_option.module_dir, "/");
417 /* Handle options -ffpe-trap= and -ffpe-summary=. */
419 static void
420 gfc_handle_fpe_option (const char *arg, bool trap)
422 int result, pos = 0, n;
423 /* precision is a backwards compatibility alias for inexact. */
424 static const char * const exception[] = { "invalid", "denormal", "zero",
425 "overflow", "underflow",
426 "inexact", "precision", NULL };
427 static const int opt_exception[] = { GFC_FPE_INVALID, GFC_FPE_DENORMAL,
428 GFC_FPE_ZERO, GFC_FPE_OVERFLOW,
429 GFC_FPE_UNDERFLOW, GFC_FPE_INEXACT,
430 GFC_FPE_INEXACT,
431 0 };
433 /* As the default for -ffpe-summary= is nonzero, set it to 0. */
434 if (!trap)
435 gfc_option.fpe_summary = 0;
437 while (*arg)
439 while (*arg == ',')
440 arg++;
442 while (arg[pos] && arg[pos] != ',')
443 pos++;
445 result = 0;
446 if (!trap && strncmp ("none", arg, pos) == 0)
448 gfc_option.fpe_summary = 0;
449 arg += pos;
450 pos = 0;
451 continue;
453 else if (!trap && strncmp ("all", arg, pos) == 0)
455 gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL
456 | GFC_FPE_ZERO | GFC_FPE_OVERFLOW
457 | GFC_FPE_UNDERFLOW | GFC_FPE_INEXACT;
458 arg += pos;
459 pos = 0;
460 continue;
462 else
463 for (n = 0; exception[n] != NULL; n++)
465 if (exception[n] && strncmp (exception[n], arg, pos) == 0)
467 if (trap)
468 gfc_option.fpe |= opt_exception[n];
469 else
470 gfc_option.fpe_summary |= opt_exception[n];
471 arg += pos;
472 pos = 0;
473 result = 1;
474 break;
477 if (!result && !trap)
478 gfc_fatal_error ("Argument to %<-ffpe-trap%> is not valid: %s", arg);
479 else if (!result)
480 gfc_fatal_error ("Argument to %<-ffpe-summary%> is not valid: %s", arg);
486 static void
487 gfc_handle_runtime_check_option (const char *arg)
489 int result, pos = 0, n;
490 static const char * const optname[] = { "all", "bounds", "array-temps",
491 "recursion", "do", "pointer",
492 "mem", NULL };
493 static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS,
494 GFC_RTCHECK_ARRAY_TEMPS,
495 GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO,
496 GFC_RTCHECK_POINTER, GFC_RTCHECK_MEM,
497 0 };
499 while (*arg)
501 while (*arg == ',')
502 arg++;
504 while (arg[pos] && arg[pos] != ',')
505 pos++;
507 result = 0;
508 for (n = 0; optname[n] != NULL; n++)
510 if (optname[n] && strncmp (optname[n], arg, pos) == 0)
512 gfc_option.rtcheck |= optmask[n];
513 arg += pos;
514 pos = 0;
515 result = 1;
516 break;
519 if (!result)
520 gfc_fatal_error ("Argument to %<-fcheck%> is not valid: %s", arg);
525 /* Handle command-line options. Returns 0 if unrecognized, 1 if
526 recognized and handled. */
528 bool
529 gfc_handle_option (size_t scode, const char *arg, int value,
530 int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED,
531 const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
533 bool result = true;
534 enum opt_code code = (enum opt_code) scode;
536 if (gfc_cpp_handle_option (scode, arg, value) == 1)
537 return true;
539 switch (code)
541 default:
542 if (cl_options[code].flags & gfc_option_lang_mask ())
543 break;
544 result = false;
545 break;
547 case OPT_fcheck_array_temporaries:
548 gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS;
549 break;
551 case OPT_fd_lines_as_code:
552 gfc_option.flag_d_lines = 1;
553 break;
555 case OPT_fd_lines_as_comments:
556 gfc_option.flag_d_lines = 0;
557 break;
559 case OPT_ffixed_form:
560 gfc_option.source_form = FORM_FIXED;
561 break;
563 case OPT_ffree_form:
564 gfc_option.source_form = FORM_FREE;
565 break;
567 case OPT_static_libgfortran:
568 #ifndef HAVE_LD_STATIC_DYNAMIC
569 gfc_fatal_error ("%<-static-libgfortran%> is not supported in this "
570 "configuration");
571 #endif
572 break;
574 case OPT_fintrinsic_modules_path:
575 case OPT_fintrinsic_modules_path_:
577 /* This is needed because omp_lib.h is in a directory together
578 with intrinsic modules. Do no warn because during testing
579 without an installed compiler, we would get lots of bogus
580 warnings for a missing include directory. */
581 gfc_add_include_path (arg, false, false, false);
583 gfc_add_intrinsic_modules_path (arg);
584 break;
586 case OPT_fpreprocessed:
587 gfc_option.flag_preprocessed = value;
588 break;
590 case OPT_fmax_identifier_length_:
591 if (value > GFC_MAX_SYMBOL_LEN)
592 gfc_fatal_error ("Maximum supported identifier length is %d",
593 GFC_MAX_SYMBOL_LEN);
594 gfc_option.max_identifier_length = value;
595 break;
597 case OPT_finit_local_zero:
598 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
599 gfc_option.flag_init_integer_value = 0;
600 flag_init_real = GFC_INIT_REAL_ZERO;
601 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
602 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
603 gfc_option.flag_init_character_value = (char)0;
604 break;
606 case OPT_finit_logical_:
607 if (!strcasecmp (arg, "false"))
608 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
609 else if (!strcasecmp (arg, "true"))
610 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_TRUE;
611 else
612 gfc_fatal_error ("Unrecognized option to %<-finit-logical%>: %s",
613 arg);
614 break;
616 case OPT_finit_integer_:
617 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
618 gfc_option.flag_init_integer_value = atoi (arg);
619 break;
621 case OPT_finit_character_:
622 if (value >= 0 && value <= 127)
624 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
625 gfc_option.flag_init_character_value = (char)value;
627 else
628 gfc_fatal_error ("The value of n in %<-finit-character=n%> must be "
629 "between 0 and 127");
630 break;
632 case OPT_I:
633 gfc_add_include_path (arg, true, false, true);
634 break;
636 case OPT_J:
637 gfc_handle_module_path_options (arg);
638 break;
640 case OPT_ffpe_trap_:
641 gfc_handle_fpe_option (arg, true);
642 break;
644 case OPT_ffpe_summary_:
645 gfc_handle_fpe_option (arg, false);
646 break;
648 case OPT_std_f95:
649 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77
650 | GFC_STD_F2008_OBS;
651 gfc_option.warn_std = GFC_STD_F95_OBS;
652 gfc_option.max_continue_fixed = 19;
653 gfc_option.max_continue_free = 39;
654 gfc_option.max_identifier_length = 31;
655 warn_ampersand = 1;
656 warn_tabs = 1;
657 break;
659 case OPT_std_f2003:
660 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
661 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008_OBS;
662 gfc_option.warn_std = GFC_STD_F95_OBS;
663 gfc_option.max_identifier_length = 63;
664 warn_ampersand = 1;
665 warn_tabs = 1;
666 break;
668 case OPT_std_f2008:
669 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
670 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS;
671 gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
672 gfc_option.max_identifier_length = 63;
673 warn_ampersand = 1;
674 warn_tabs = 1;
675 break;
677 case OPT_std_f2008ts:
678 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
679 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS
680 | GFC_STD_F2008_TS;
681 gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
682 gfc_option.max_identifier_length = 63;
683 warn_ampersand = 1;
684 warn_tabs = 1;
685 break;
687 case OPT_std_gnu:
688 set_default_std_flags ();
689 break;
691 case OPT_std_legacy:
692 set_default_std_flags ();
693 gfc_option.warn_std = 0;
694 break;
696 case OPT_fshort_enums:
697 /* Handled in language-independent code. */
698 break;
700 case OPT_fcheck_:
701 gfc_handle_runtime_check_option (arg);
702 break;
705 Fortran_handle_option_auto (&global_options, &global_options_set,
706 scode, arg, value,
707 gfc_option_lang_mask (), kind,
708 loc, handlers, global_dc);
709 return result;
713 /* Return a string with the options passed to the compiler; used for
714 Fortran's compiler_options() intrinsic. */
716 char *
717 gfc_get_option_string (void)
719 unsigned j;
720 size_t len, pos;
721 char *result;
723 /* Allocate and return a one-character string with '\0'. */
724 if (!save_decoded_options_count)
725 return XCNEWVEC (char, 1);
727 /* Determine required string length. */
729 len = 0;
730 for (j = 1; j < save_decoded_options_count; j++)
732 switch (save_decoded_options[j].opt_index)
734 case OPT_o:
735 case OPT_d:
736 case OPT_dumpbase:
737 case OPT_dumpdir:
738 case OPT_auxbase:
739 case OPT_quiet:
740 case OPT_version:
741 case OPT_fintrinsic_modules_path:
742 case OPT_fintrinsic_modules_path_:
743 /* Ignore these. */
744 break;
745 default:
746 /* Ignore file names. */
747 if (save_decoded_options[j].orig_option_with_args_text[0] == '-')
748 len += 1
749 + strlen (save_decoded_options[j].orig_option_with_args_text);
753 result = XCNEWVEC (char, len);
755 pos = 0;
756 for (j = 1; j < save_decoded_options_count; j++)
758 switch (save_decoded_options[j].opt_index)
760 case OPT_o:
761 case OPT_d:
762 case OPT_dumpbase:
763 case OPT_dumpdir:
764 case OPT_auxbase:
765 case OPT_quiet:
766 case OPT_version:
767 case OPT_fintrinsic_modules_path:
768 case OPT_fintrinsic_modules_path_:
769 /* Ignore these. */
770 continue;
772 case OPT_cpp_:
773 /* Use "-cpp" rather than "-cpp=<temporary file>". */
774 len = 4;
775 break;
777 default:
778 /* Ignore file names. */
779 if (save_decoded_options[j].orig_option_with_args_text[0] != '-')
780 continue;
782 len = strlen (save_decoded_options[j].orig_option_with_args_text);
785 memcpy (&result[pos], save_decoded_options[j].orig_option_with_args_text, len);
786 pos += len;
787 result[pos++] = ' ';
790 result[--pos] = '\0';
791 return result;