1 /* Parse and display command line options.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 Free Software Foundation, Inc.
5 Contributed by Andy Vaught
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
25 #include "coretypes.h"
30 #include "toplev.h" /* For save_decoded_options. */
33 #include "tree-inline.h"
37 #include "diagnostic-core.h" /* For sorry. */
40 gfc_option_t gfc_option;
43 /* Set flags that control warnings and errors for different
44 Fortran standards to their default values. Keep in sync with
45 libgfortran/runtime/compile_options.c (init_compile_options). */
48 set_default_std_flags (void)
50 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
51 | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
52 | GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY;
53 gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
57 /* Return language mask for Fortran options. */
60 gfc_option_lang_mask (void)
65 /* Initialize options structure OPTS. */
68 gfc_init_options_struct (struct gcc_options *opts)
70 opts->x_flag_errno_math = 0;
71 opts->x_flag_associative_math = -1;
74 /* Get ready for options handling. Keep in sync with
75 libgfortran/runtime/compile_options.c (init_compile_options). */
78 gfc_init_options (unsigned int decoded_options_count,
79 struct cl_decoded_option *decoded_options)
81 gfc_source_file = NULL;
82 gfc_option.module_dir = NULL;
83 gfc_option.source_form = FORM_UNKNOWN;
84 gfc_option.fixed_line_length = 72;
85 gfc_option.free_line_length = 132;
86 gfc_option.max_continue_fixed = 255;
87 gfc_option.max_continue_free = 255;
88 gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
89 gfc_option.max_subrecord_length = 0;
90 gfc_option.flag_max_array_constructor = 65535;
91 gfc_option.convert = GFC_CONVERT_NATIVE;
92 gfc_option.record_marker = 0;
93 gfc_option.dump_fortran_original = 0;
94 gfc_option.dump_fortran_optimized = 0;
96 gfc_option.warn_aliasing = 0;
97 gfc_option.warn_ampersand = 0;
98 gfc_option.warn_character_truncation = 0;
99 gfc_option.warn_array_temp = 0;
100 gfc_option.gfc_warn_conversion = 0;
101 gfc_option.warn_conversion_extra = 0;
102 gfc_option.warn_function_elimination = 0;
103 gfc_option.warn_implicit_interface = 0;
104 gfc_option.warn_line_truncation = 0;
105 gfc_option.warn_surprising = 0;
106 gfc_option.warn_tabs = 1;
107 gfc_option.warn_underflow = 1;
108 gfc_option.warn_intrinsic_shadow = 0;
109 gfc_option.warn_intrinsics_std = 0;
110 gfc_option.warn_align_commons = 1;
111 gfc_option.warn_unused_dummy_argument = 0;
112 gfc_option.max_errors = 25;
114 gfc_option.flag_all_intrinsics = 0;
115 gfc_option.flag_default_double = 0;
116 gfc_option.flag_default_integer = 0;
117 gfc_option.flag_default_real = 0;
118 gfc_option.flag_dollar_ok = 0;
119 gfc_option.flag_underscoring = 1;
120 gfc_option.flag_whole_file = 1;
121 gfc_option.flag_f2c = 0;
122 gfc_option.flag_second_underscore = -1;
123 gfc_option.flag_implicit_none = 0;
125 /* Default value of flag_max_stack_var_size is set in gfc_post_options. */
126 gfc_option.flag_max_stack_var_size = -2;
127 gfc_option.flag_stack_arrays = 0;
129 gfc_option.flag_range_check = 1;
130 gfc_option.flag_pack_derived = 0;
131 gfc_option.flag_repack_arrays = 0;
132 gfc_option.flag_preprocessed = 0;
133 gfc_option.flag_automatic = 1;
134 gfc_option.flag_backslash = 0;
135 gfc_option.flag_module_private = 0;
136 gfc_option.flag_backtrace = 0;
137 gfc_option.flag_allow_leading_underscore = 0;
138 gfc_option.flag_dump_core = 0;
139 gfc_option.flag_external_blas = 0;
140 gfc_option.blas_matmul_limit = 30;
141 gfc_option.flag_cray_pointer = 0;
142 gfc_option.flag_d_lines = -1;
143 gfc_option.gfc_flag_openmp = 0;
144 gfc_option.flag_sign_zero = 1;
145 gfc_option.flag_recursive = 0;
146 gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF;
147 gfc_option.flag_init_integer_value = 0;
148 gfc_option.flag_init_real = GFC_INIT_REAL_OFF;
149 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_OFF;
150 gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF;
151 gfc_option.flag_init_character_value = (char)0;
152 gfc_option.flag_align_commons = 1;
153 gfc_option.flag_protect_parens = 1;
154 gfc_option.flag_realloc_lhs = -1;
155 gfc_option.flag_aggressive_function_elimination = 0;
156 gfc_option.flag_frontend_optimize = -1;
159 gfc_option.rtcheck = 0;
160 gfc_option.coarray = GFC_FCOARRAY_NONE;
162 set_default_std_flags ();
164 /* Initialize cpp-related options. */
165 gfc_cpp_init_options (decoded_options_count, decoded_options);
169 /* Determine the source form from the filename extension. We assume
170 case insensitivity. */
172 static gfc_source_form
173 form_from_filename (const char *filename)
177 const char *extension;
178 gfc_source_form form;
205 }; /* sentinel value */
207 gfc_source_form f_form;
211 /* Find end of file name. Note, filename is either a NULL pointer or
212 a NUL terminated string. */
214 while (filename[i] != '\0')
217 /* Find last period. */
218 while (i >= 0 && (filename[i] != '.'))
221 /* Did we see a file extension? */
223 return FORM_UNKNOWN; /* Nope */
225 /* Get file extension and compare it to others. */
226 fileext = &(filename[i]);
229 f_form = FORM_UNKNOWN;
233 if (strcasecmp (fileext, exttype[i].extension) == 0)
235 f_form = exttype[i].form;
239 while (exttype[i].form != FORM_UNKNOWN);
245 /* Finalize commandline options. */
248 gfc_post_options (const char **pfilename)
250 const char *filename = *pfilename, *canon_source_file = NULL;
254 /* Excess precision other than "fast" requires front-end
256 if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD
257 && TARGET_FLT_EVAL_METHOD_NON_DEFAULT)
258 sorry ("-fexcess-precision=standard for Fortran");
259 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
261 /* Whole program needs whole file mode. */
262 if (flag_whole_program)
263 gfc_option.flag_whole_file = 1;
265 /* Enable whole-file mode if LTO is in effect. */
267 gfc_option.flag_whole_file = 1;
269 /* Fortran allows associative math - but we cannot reassociate if
270 we want traps or signed zeros. Cf. also flag_protect_parens. */
271 if (flag_associative_math == -1)
272 flag_associative_math = (!flag_trapping_math && !flag_signed_zeros);
274 /* By default, disable (re)allocation during assignment for -std=f95,
275 and enable it for F2003/F2008/GNU/Legacy. */
276 if (gfc_option.flag_realloc_lhs == -1)
278 if (gfc_option.allow_std & GFC_STD_F2003)
279 gfc_option.flag_realloc_lhs = 1;
281 gfc_option.flag_realloc_lhs = 0;
284 /* -fbounds-check is equivalent to -fcheck=bounds */
285 if (flag_bounds_check)
286 gfc_option.rtcheck |= GFC_RTCHECK_BOUNDS;
288 if (flag_compare_debug)
289 gfc_option.dump_fortran_original = 0;
291 /* Make -fmax-errors visible to gfortran's diagnostic machinery. */
292 if (global_options_set.x_flag_max_errors)
293 gfc_option.max_errors = flag_max_errors;
295 /* Verify the input file name. */
296 if (!filename || strcmp (filename, "-") == 0)
301 if (gfc_option.flag_preprocessed)
303 /* For preprocessed files, if the first tokens are of the form # NUM.
304 handle the directives so we know the original file name. */
305 gfc_source_file = gfc_read_orig_filename (filename, &canon_source_file);
306 if (gfc_source_file == NULL)
307 gfc_source_file = filename;
309 *pfilename = gfc_source_file;
312 gfc_source_file = filename;
314 if (canon_source_file == NULL)
315 canon_source_file = gfc_source_file;
317 /* Adds the path where the source file is to the list of include files. */
319 i = strlen (canon_source_file);
320 while (i > 0 && !IS_DIR_SEPARATOR (canon_source_file[i]))
325 source_path = (char *) alloca (i + 1);
326 memcpy (source_path, canon_source_file, i);
328 gfc_add_include_path (source_path, true, true);
331 gfc_add_include_path (".", true, true);
333 if (canon_source_file != gfc_source_file)
334 free (CONST_CAST (char *, canon_source_file));
336 /* Decide which form the file will be read in as. */
338 if (gfc_option.source_form != FORM_UNKNOWN)
339 gfc_current_form = gfc_option.source_form;
342 gfc_current_form = form_from_filename (filename);
344 if (gfc_current_form == FORM_UNKNOWN)
346 gfc_current_form = FORM_FREE;
347 gfc_warning_now ("Reading file '%s' as free form",
348 (filename[0] == '\0') ? "<stdin>" : filename);
352 /* If the user specified -fd-lines-as-{code|comments} verify that we're
354 if (gfc_current_form == FORM_FREE)
356 if (gfc_option.flag_d_lines == 0)
357 gfc_warning_now ("'-fd-lines-as-comments' has no effect "
359 else if (gfc_option.flag_d_lines == 1)
360 gfc_warning_now ("'-fd-lines-as-code' has no effect in free form");
363 /* If -pedantic, warn about the use of GNU extensions. */
364 if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0)
365 gfc_option.warn_std |= GFC_STD_GNU;
366 /* -std=legacy -pedantic is effectively -std=gnu. */
367 if (pedantic && (gfc_option.allow_std & GFC_STD_LEGACY) != 0)
368 gfc_option.warn_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_LEGACY;
370 /* If the user didn't explicitly specify -f(no)-second-underscore we
371 use it if we're trying to be compatible with f2c, and not
373 if (gfc_option.flag_second_underscore == -1)
374 gfc_option.flag_second_underscore = gfc_option.flag_f2c;
376 if (!gfc_option.flag_automatic && gfc_option.flag_max_stack_var_size != -2
377 && gfc_option.flag_max_stack_var_size != 0)
378 gfc_warning_now ("Flag -fno-automatic overwrites -fmax-stack-var-size=%d",
379 gfc_option.flag_max_stack_var_size);
380 else if (!gfc_option.flag_automatic && gfc_option.flag_recursive)
381 gfc_warning_now ("Flag -fno-automatic overwrites -frecursive");
382 else if (!gfc_option.flag_automatic && gfc_option.gfc_flag_openmp)
383 gfc_warning_now ("Flag -fno-automatic overwrites -frecursive implied by "
385 else if (gfc_option.flag_max_stack_var_size != -2
386 && gfc_option.flag_recursive)
387 gfc_warning_now ("Flag -frecursive overwrites -fmax-stack-var-size=%d",
388 gfc_option.flag_max_stack_var_size);
389 else if (gfc_option.flag_max_stack_var_size != -2
390 && gfc_option.gfc_flag_openmp)
391 gfc_warning_now ("Flag -fmax-stack-var-size=%d overwrites -frecursive "
392 "implied by -fopenmp",
393 gfc_option.flag_max_stack_var_size);
395 /* Implement -frecursive as -fmax-stack-var-size=-1. */
396 if (gfc_option.flag_recursive)
397 gfc_option.flag_max_stack_var_size = -1;
399 /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
400 if (gfc_option.flag_max_stack_var_size == -2 && gfc_option.gfc_flag_openmp
401 && gfc_option.flag_automatic)
403 gfc_option.flag_recursive = 1;
404 gfc_option.flag_max_stack_var_size = -1;
408 if (gfc_option.flag_max_stack_var_size == -2)
409 gfc_option.flag_max_stack_var_size = 32768;
411 /* Implement -fno-automatic as -fmax-stack-var-size=0. */
412 if (!gfc_option.flag_automatic)
413 gfc_option.flag_max_stack_var_size = 0;
417 gfc_option.warn_ampersand = 1;
418 gfc_option.warn_tabs = 0;
421 if (pedantic && gfc_option.flag_whole_file)
422 gfc_option.flag_whole_file = 2;
424 /* Optimization implies front end optimization, unless the user
425 specified it directly. */
427 if (gfc_option.flag_frontend_optimize == -1)
428 gfc_option.flag_frontend_optimize = optimize;
430 gfc_cpp_post_options ();
432 /* FIXME: return gfc_cpp_preprocess_only ();
434 The return value of this function indicates whether the
435 backend needs to be initialized. On -E, we don't need
436 the backend. However, if we return 'true' here, an
437 ICE occurs. Initializing the backend doesn't hurt much,
438 hence, for now we can live with it as is. */
443 /* Set the options for -Wall. */
446 set_Wall (int setting)
448 gfc_option.warn_aliasing = setting;
449 gfc_option.warn_ampersand = setting;
450 gfc_option.gfc_warn_conversion = setting;
451 gfc_option.warn_line_truncation = setting;
452 gfc_option.warn_surprising = setting;
453 gfc_option.warn_tabs = !setting;
454 gfc_option.warn_underflow = setting;
455 gfc_option.warn_intrinsic_shadow = setting;
456 gfc_option.warn_intrinsics_std = setting;
457 gfc_option.warn_character_truncation = setting;
458 gfc_option.warn_unused_dummy_argument = setting;
460 warn_unused = setting;
461 warn_return_type = setting;
462 warn_switch = setting;
463 warn_uninitialized = setting;
464 warn_maybe_uninitialized = setting;
469 gfc_handle_module_path_options (const char *arg)
472 if (gfc_option.module_dir != NULL)
473 gfc_fatal_error ("gfortran: Only one -J option allowed");
475 gfc_option.module_dir = XCNEWVEC (char, strlen (arg) + 2);
476 strcpy (gfc_option.module_dir, arg);
478 gfc_add_include_path (gfc_option.module_dir, true, false);
480 strcat (gfc_option.module_dir, "/");
485 gfc_handle_fpe_trap_option (const char *arg)
487 int result, pos = 0, n;
488 static const char * const exception[] = { "invalid", "denormal", "zero",
489 "overflow", "underflow",
491 static const int opt_exception[] = { GFC_FPE_INVALID, GFC_FPE_DENORMAL,
492 GFC_FPE_ZERO, GFC_FPE_OVERFLOW,
493 GFC_FPE_UNDERFLOW, GFC_FPE_PRECISION,
501 while (arg[pos] && arg[pos] != ',')
505 for (n = 0; exception[n] != NULL; n++)
507 if (exception[n] && strncmp (exception[n], arg, pos) == 0)
509 gfc_option.fpe |= opt_exception[n];
517 gfc_fatal_error ("Argument to -ffpe-trap is not valid: %s", arg);
523 gfc_handle_coarray_option (const char *arg)
525 if (strcmp (arg, "none") == 0)
526 gfc_option.coarray = GFC_FCOARRAY_NONE;
527 else if (strcmp (arg, "single") == 0)
528 gfc_option.coarray = GFC_FCOARRAY_SINGLE;
529 else if (strcmp (arg, "lib") == 0)
530 gfc_option.coarray = GFC_FCOARRAY_LIB;
532 gfc_fatal_error ("Argument to -fcoarray is not valid: %s", arg);
537 gfc_handle_runtime_check_option (const char *arg)
539 int result, pos = 0, n;
540 static const char * const optname[] = { "all", "bounds", "array-temps",
541 "recursion", "do", "pointer",
543 static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS,
544 GFC_RTCHECK_ARRAY_TEMPS,
545 GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO,
546 GFC_RTCHECK_POINTER, GFC_RTCHECK_MEM,
554 while (arg[pos] && arg[pos] != ',')
558 for (n = 0; optname[n] != NULL; n++)
560 if (optname[n] && strncmp (optname[n], arg, pos) == 0)
562 gfc_option.rtcheck |= optmask[n];
570 gfc_fatal_error ("Argument to -fcheck is not valid: %s", arg);
575 /* Handle command-line options. Returns 0 if unrecognized, 1 if
576 recognized and handled. */
579 gfc_handle_option (size_t scode, const char *arg, int value,
580 int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED,
581 const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
584 enum opt_code code = (enum opt_code) scode;
586 if (gfc_cpp_handle_option (scode, arg, value) == 1)
600 gfc_option.warn_aliasing = value;
604 gfc_option.warn_ampersand = value;
607 case OPT_Warray_temporaries:
608 gfc_option.warn_array_temp = value;
611 case OPT_Wcharacter_truncation:
612 gfc_option.warn_character_truncation = value;
615 case OPT_Wconversion:
616 gfc_option.gfc_warn_conversion = value;
619 case OPT_Wconversion_extra:
620 gfc_option.warn_conversion_extra = value;
623 case OPT_Wfunction_elimination:
624 gfc_option.warn_function_elimination = value;
627 case OPT_Wimplicit_interface:
628 gfc_option.warn_implicit_interface = value;
631 case OPT_Wimplicit_procedure:
632 gfc_option.warn_implicit_procedure = value;
635 case OPT_Wline_truncation:
636 gfc_option.warn_line_truncation = value;
639 case OPT_Wreturn_type:
640 warn_return_type = value;
643 case OPT_Wsurprising:
644 gfc_option.warn_surprising = value;
648 gfc_option.warn_tabs = value;
652 gfc_option.warn_underflow = value;
655 case OPT_Wintrinsic_shadow:
656 gfc_option.warn_intrinsic_shadow = value;
659 case OPT_Walign_commons:
660 gfc_option.warn_align_commons = value;
663 case OPT_Wunused_dummy_argument:
664 gfc_option.warn_unused_dummy_argument = value;
667 case OPT_fall_intrinsics:
668 gfc_option.flag_all_intrinsics = 1;
672 gfc_option.flag_automatic = value;
675 case OPT_fallow_leading_underscore:
676 gfc_option.flag_allow_leading_underscore = value;
680 gfc_option.flag_backslash = value;
684 gfc_option.flag_backtrace = value;
687 case OPT_fcheck_array_temporaries:
688 gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS;
692 gfc_option.flag_dump_core = value;
695 case OPT_fcray_pointer:
696 gfc_option.flag_cray_pointer = value;
700 gfc_option.flag_f2c = value;
704 gfc_option.flag_dollar_ok = value;
707 case OPT_fexternal_blas:
708 gfc_option.flag_external_blas = value;
711 case OPT_fblas_matmul_limit_:
712 gfc_option.blas_matmul_limit = value;
715 case OPT_fd_lines_as_code:
716 gfc_option.flag_d_lines = 1;
719 case OPT_fd_lines_as_comments:
720 gfc_option.flag_d_lines = 0;
723 case OPT_fdump_fortran_original:
724 case OPT_fdump_parse_tree:
725 gfc_option.dump_fortran_original = value;
728 case OPT_fdump_fortran_optimized:
729 gfc_option.dump_fortran_optimized = value;
732 case OPT_ffixed_form:
733 gfc_option.source_form = FORM_FIXED;
736 case OPT_ffixed_line_length_none:
737 gfc_option.fixed_line_length = 0;
740 case OPT_ffixed_line_length_:
741 if (value != 0 && value < 7)
742 gfc_fatal_error ("Fixed line length must be at least seven.");
743 gfc_option.fixed_line_length = value;
747 gfc_option.source_form = FORM_FREE;
751 gfc_option.gfc_flag_openmp = value;
754 case OPT_ffree_line_length_none:
755 gfc_option.free_line_length = 0;
758 case OPT_ffree_line_length_:
759 if (value != 0 && value < 4)
760 gfc_fatal_error ("Free line length must be at least three.");
761 gfc_option.free_line_length = value;
764 case OPT_funderscoring:
765 gfc_option.flag_underscoring = value;
768 case OPT_fwhole_file:
769 gfc_option.flag_whole_file = value;
772 case OPT_fsecond_underscore:
773 gfc_option.flag_second_underscore = value;
776 case OPT_static_libgfortran:
777 #ifndef HAVE_LD_STATIC_DYNAMIC
778 gfc_fatal_error ("-static-libgfortran is not supported in this "
783 case OPT_fimplicit_none:
784 gfc_option.flag_implicit_none = value;
787 case OPT_fintrinsic_modules_path:
788 gfc_add_include_path (arg, false, false);
789 gfc_add_intrinsic_modules_path (arg);
792 case OPT_fmax_array_constructor_:
793 gfc_option.flag_max_array_constructor = value > 65535 ? value : 65535;
796 case OPT_fmax_stack_var_size_:
797 gfc_option.flag_max_stack_var_size = value;
800 case OPT_fstack_arrays:
801 gfc_option.flag_stack_arrays = value;
804 case OPT_fmodule_private:
805 gfc_option.flag_module_private = value;
808 case OPT_frange_check:
809 gfc_option.flag_range_check = value;
812 case OPT_fpack_derived:
813 gfc_option.flag_pack_derived = value;
816 case OPT_frepack_arrays:
817 gfc_option.flag_repack_arrays = value;
820 case OPT_fpreprocessed:
821 gfc_option.flag_preprocessed = value;
824 case OPT_fmax_identifier_length_:
825 if (value > GFC_MAX_SYMBOL_LEN)
826 gfc_fatal_error ("Maximum supported identifier length is %d",
828 gfc_option.max_identifier_length = value;
831 case OPT_fdefault_integer_8:
832 gfc_option.flag_default_integer = value;
835 case OPT_fdefault_real_8:
836 gfc_option.flag_default_real = value;
839 case OPT_fdefault_double_8:
840 gfc_option.flag_default_double = value;
843 case OPT_finit_local_zero:
844 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
845 gfc_option.flag_init_integer_value = 0;
846 gfc_option.flag_init_real = GFC_INIT_REAL_ZERO;
847 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
848 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
849 gfc_option.flag_init_character_value = (char)0;
852 case OPT_finit_logical_:
853 if (!strcasecmp (arg, "false"))
854 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
855 else if (!strcasecmp (arg, "true"))
856 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_TRUE;
858 gfc_fatal_error ("Unrecognized option to -finit-logical: %s",
862 case OPT_finit_real_:
863 if (!strcasecmp (arg, "zero"))
864 gfc_option.flag_init_real = GFC_INIT_REAL_ZERO;
865 else if (!strcasecmp (arg, "nan"))
866 gfc_option.flag_init_real = GFC_INIT_REAL_NAN;
867 else if (!strcasecmp (arg, "snan"))
868 gfc_option.flag_init_real = GFC_INIT_REAL_SNAN;
869 else if (!strcasecmp (arg, "inf"))
870 gfc_option.flag_init_real = GFC_INIT_REAL_INF;
871 else if (!strcasecmp (arg, "-inf"))
872 gfc_option.flag_init_real = GFC_INIT_REAL_NEG_INF;
874 gfc_fatal_error ("Unrecognized option to -finit-real: %s",
878 case OPT_finit_integer_:
879 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
880 gfc_option.flag_init_integer_value = atoi (arg);
883 case OPT_finit_character_:
884 if (value >= 0 && value <= 127)
886 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
887 gfc_option.flag_init_character_value = (char)value;
890 gfc_fatal_error ("The value of n in -finit-character=n must be "
891 "between 0 and 127");
895 gfc_add_include_path (arg, true, false);
899 gfc_handle_module_path_options (arg);
903 gfc_option.flag_sign_zero = value;
907 gfc_handle_fpe_trap_option (arg);
911 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77
913 gfc_option.warn_std = GFC_STD_F95_OBS;
914 gfc_option.max_continue_fixed = 19;
915 gfc_option.max_continue_free = 39;
916 gfc_option.max_identifier_length = 31;
917 gfc_option.warn_ampersand = 1;
918 gfc_option.warn_tabs = 0;
922 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
923 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008_OBS;
924 gfc_option.warn_std = GFC_STD_F95_OBS;
925 gfc_option.max_identifier_length = 63;
926 gfc_option.warn_ampersand = 1;
927 gfc_option.warn_tabs = 0;
931 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
932 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS;
933 gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
934 gfc_option.max_identifier_length = 63;
935 gfc_option.warn_ampersand = 1;
936 gfc_option.warn_tabs = 0;
940 set_default_std_flags ();
944 set_default_std_flags ();
945 gfc_option.warn_std = 0;
948 case OPT_Wintrinsics_std:
949 gfc_option.warn_intrinsics_std = value;
952 case OPT_fshort_enums:
953 /* Handled in language-independent code. */
956 case OPT_fconvert_little_endian:
957 gfc_option.convert = GFC_CONVERT_LITTLE;
960 case OPT_fconvert_big_endian:
961 gfc_option.convert = GFC_CONVERT_BIG;
964 case OPT_fconvert_native:
965 gfc_option.convert = GFC_CONVERT_NATIVE;
968 case OPT_fconvert_swap:
969 gfc_option.convert = GFC_CONVERT_SWAP;
972 case OPT_frecord_marker_4:
973 gfc_option.record_marker = 4;
976 case OPT_frecord_marker_8:
977 gfc_option.record_marker = 8;
980 case OPT_fmax_subrecord_length_:
981 if (value > MAX_SUBRECORD_LENGTH)
982 gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
983 MAX_SUBRECORD_LENGTH);
985 gfc_option.max_subrecord_length = value;
989 gfc_option.flag_recursive = value;
992 case OPT_falign_commons:
993 gfc_option.flag_align_commons = value;
996 case OPT_faggressive_function_elimination:
997 gfc_option.flag_aggressive_function_elimination = value;
1000 case OPT_ffrontend_optimize:
1001 gfc_option.flag_frontend_optimize = value;
1004 case OPT_fprotect_parens:
1005 gfc_option.flag_protect_parens = value;
1008 case OPT_frealloc_lhs:
1009 gfc_option.flag_realloc_lhs = value;
1013 gfc_handle_runtime_check_option (arg);
1017 gfc_handle_coarray_option (arg);
1025 /* Return a string with the options passed to the compiler; used for
1026 Fortran's compiler_options() intrinsic. */
1029 gfc_get_option_string (void)
1035 /* Determine required string length. */
1038 for (j = 1; j < save_decoded_options_count; j++)
1040 switch (save_decoded_options[j].opt_index)
1049 case OPT_fintrinsic_modules_path:
1053 /* Ignore file names. */
1054 if (save_decoded_options[j].orig_option_with_args_text[0] == '-')
1056 + strlen (save_decoded_options[j].orig_option_with_args_text);
1060 result = XCNEWVEC (char, len);
1063 for (j = 1; j < save_decoded_options_count; j++)
1065 switch (save_decoded_options[j].opt_index)
1074 case OPT_fintrinsic_modules_path:
1079 /* Use "-cpp" rather than "-cpp=<temporary file>". */
1084 /* Ignore file names. */
1085 if (save_decoded_options[j].orig_option_with_args_text[0] != '-')
1088 len = strlen (save_decoded_options[j].orig_option_with_args_text);
1091 memcpy (&result[pos], save_decoded_options[j].orig_option_with_args_text, len);
1093 result[pos++] = ' ';
1096 result[--pos] = '\0';