Merge from mainline (154736:156693)
[official-gcc/graphite-test-results.git] / gcc / fortran / options.c
blob9296a0be66769d4c5b6040e137cefb015dd9dbe3
1 /* Parse and display command line options.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 Free Software Foundation, Inc.
4 Contributed by Andy Vaught
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tree.h"
26 #include "flags.h"
27 #include "intl.h"
28 #include "opts.h"
29 #include "options.h"
30 #include "params.h"
31 #include "tree-inline.h"
32 #include "gfortran.h"
33 #include "target.h"
34 #include "cpp.h"
35 #include "toplev.h"
36 #include "tm.h"
38 gfc_option_t gfc_option;
41 /* Set flags that control warnings and errors for different
42 Fortran standards to their default values. Keep in sync with
43 libgfortran/runtime/compile_options.c (init_compile_options). */
45 static void
46 set_default_std_flags (void)
48 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
49 | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
50 | GFC_STD_GNU | GFC_STD_LEGACY;
51 gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
55 /* Get ready for options handling. Keep in sync with
56 libgfortran/runtime/compile_options.c (init_compile_options). */
58 unsigned int
59 gfc_init_options (unsigned int argc, const char **argv)
61 gfc_source_file = NULL;
62 gfc_option.module_dir = NULL;
63 gfc_option.source_form = FORM_UNKNOWN;
64 gfc_option.fixed_line_length = 72;
65 gfc_option.free_line_length = 132;
66 gfc_option.max_continue_fixed = 255;
67 gfc_option.max_continue_free = 255;
68 gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
69 gfc_option.max_subrecord_length = 0;
70 gfc_option.flag_max_array_constructor = 65535;
71 gfc_option.convert = GFC_CONVERT_NATIVE;
72 gfc_option.record_marker = 0;
73 gfc_option.dump_parse_tree = 0;
75 gfc_option.warn_aliasing = 0;
76 gfc_option.warn_ampersand = 0;
77 gfc_option.warn_character_truncation = 0;
78 gfc_option.warn_array_temp = 0;
79 gfc_option.warn_conversion = 0;
80 gfc_option.warn_implicit_interface = 0;
81 gfc_option.warn_line_truncation = 0;
82 gfc_option.warn_surprising = 0;
83 gfc_option.warn_tabs = 1;
84 gfc_option.warn_underflow = 1;
85 gfc_option.warn_intrinsic_shadow = 0;
86 gfc_option.warn_intrinsics_std = 0;
87 gfc_option.warn_align_commons = 1;
88 gfc_option.max_errors = 25;
90 gfc_option.flag_all_intrinsics = 0;
91 gfc_option.flag_default_double = 0;
92 gfc_option.flag_default_integer = 0;
93 gfc_option.flag_default_real = 0;
94 gfc_option.flag_dollar_ok = 0;
95 gfc_option.flag_underscoring = 1;
96 gfc_option.flag_whole_file = 0;
97 gfc_option.flag_f2c = 0;
98 gfc_option.flag_second_underscore = -1;
99 gfc_option.flag_implicit_none = 0;
101 /* Default value of flag_max_stack_var_size is set in gfc_post_options. */
102 gfc_option.flag_max_stack_var_size = -2;
104 gfc_option.flag_range_check = 1;
105 gfc_option.flag_pack_derived = 0;
106 gfc_option.flag_repack_arrays = 0;
107 gfc_option.flag_preprocessed = 0;
108 gfc_option.flag_automatic = 1;
109 gfc_option.flag_backslash = 0;
110 gfc_option.flag_module_private = 0;
111 gfc_option.flag_backtrace = 0;
112 gfc_option.flag_allow_leading_underscore = 0;
113 gfc_option.flag_dump_core = 0;
114 gfc_option.flag_external_blas = 0;
115 gfc_option.blas_matmul_limit = 30;
116 gfc_option.flag_cray_pointer = 0;
117 gfc_option.flag_d_lines = -1;
118 gfc_option.flag_openmp = 0;
119 gfc_option.flag_sign_zero = 1;
120 gfc_option.flag_recursive = 0;
121 gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF;
122 gfc_option.flag_init_integer_value = 0;
123 gfc_option.flag_init_real = GFC_INIT_REAL_OFF;
124 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_OFF;
125 gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF;
126 gfc_option.flag_init_character_value = (char)0;
127 gfc_option.flag_align_commons = 1;
129 gfc_option.fpe = 0;
130 gfc_option.rtcheck = 0;
132 /* Argument pointers cannot point to anything but their argument. */
133 flag_argument_noalias = 3;
135 flag_errno_math = 0;
137 set_default_std_flags ();
139 /* -fshort-enums can be default on some targets. */
140 flag_short_enums = targetm.default_short_enums ();
142 /* Initialize cpp-related options. */
143 gfc_cpp_init_options(argc, argv);
145 return CL_Fortran;
149 /* Determine the source form from the filename extension. We assume
150 case insensitivity. */
152 static gfc_source_form
153 form_from_filename (const char *filename)
155 static const struct
157 const char *extension;
158 gfc_source_form form;
160 exttype[] =
163 ".f90", FORM_FREE}
166 ".f95", FORM_FREE}
169 ".f03", FORM_FREE}
172 ".f08", FORM_FREE}
175 ".f", FORM_FIXED}
178 ".for", FORM_FIXED}
181 ".ftn", FORM_FIXED}
184 "", FORM_UNKNOWN}
185 }; /* sentinel value */
187 gfc_source_form f_form;
188 const char *fileext;
189 int i;
191 /* Find end of file name. Note, filename is either a NULL pointer or
192 a NUL terminated string. */
193 i = 0;
194 while (filename[i] != '\0')
195 i++;
197 /* Find last period. */
198 while (i >= 0 && (filename[i] != '.'))
199 i--;
201 /* Did we see a file extension? */
202 if (i < 0)
203 return FORM_UNKNOWN; /* Nope */
205 /* Get file extension and compare it to others. */
206 fileext = &(filename[i]);
208 i = -1;
209 f_form = FORM_UNKNOWN;
212 i++;
213 if (strcasecmp (fileext, exttype[i].extension) == 0)
215 f_form = exttype[i].form;
216 break;
219 while (exttype[i].form != FORM_UNKNOWN);
221 return f_form;
225 /* Finalize commandline options. */
227 bool
228 gfc_post_options (const char **pfilename)
230 const char *filename = *pfilename, *canon_source_file = NULL;
231 char *source_path;
232 int i;
234 /* Excess precision other than "fast" requires front-end
235 support. */
236 if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD
237 && TARGET_FLT_EVAL_METHOD_NON_DEFAULT)
238 sorry ("-fexcess-precision=standard for Fortran");
239 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
241 /* Whole program needs whole file mode. */
242 if (flag_whole_program)
243 gfc_option.flag_whole_file = 1;
245 /* Enable whole-file mode if LTO is in effect. */
246 if (flag_lto || flag_whopr)
247 gfc_option.flag_whole_file = 1;
249 /* -fbounds-check is equivalent to -fcheck=bounds */
250 if (flag_bounds_check)
251 gfc_option.rtcheck |= GFC_RTCHECK_BOUNDS;
253 if (flag_compare_debug)
254 gfc_option.dump_parse_tree = 0;
256 /* Verify the input file name. */
257 if (!filename || strcmp (filename, "-") == 0)
259 filename = "";
262 if (gfc_option.flag_preprocessed)
264 /* For preprocessed files, if the first tokens are of the form # NUM.
265 handle the directives so we know the original file name. */
266 gfc_source_file = gfc_read_orig_filename (filename, &canon_source_file);
267 if (gfc_source_file == NULL)
268 gfc_source_file = filename;
269 else
270 *pfilename = gfc_source_file;
272 else
273 gfc_source_file = filename;
275 if (canon_source_file == NULL)
276 canon_source_file = gfc_source_file;
278 /* Adds the path where the source file is to the list of include files. */
280 i = strlen (canon_source_file);
281 while (i > 0 && !IS_DIR_SEPARATOR (canon_source_file[i]))
282 i--;
284 if (i != 0)
286 source_path = (char *) alloca (i + 1);
287 memcpy (source_path, canon_source_file, i);
288 source_path[i] = 0;
289 gfc_add_include_path (source_path, true, true);
291 else
292 gfc_add_include_path (".", true, true);
294 if (canon_source_file != gfc_source_file)
295 gfc_free (CONST_CAST (char *, canon_source_file));
297 /* Decide which form the file will be read in as. */
299 if (gfc_option.source_form != FORM_UNKNOWN)
300 gfc_current_form = gfc_option.source_form;
301 else
303 gfc_current_form = form_from_filename (filename);
305 if (gfc_current_form == FORM_UNKNOWN)
307 gfc_current_form = FORM_FREE;
308 gfc_warning_now ("Reading file '%s' as free form",
309 (filename[0] == '\0') ? "<stdin>" : filename);
313 /* If the user specified -fd-lines-as-{code|comments} verify that we're
314 in fixed form. */
315 if (gfc_current_form == FORM_FREE)
317 if (gfc_option.flag_d_lines == 0)
318 gfc_warning_now ("'-fd-lines-as-comments' has no effect "
319 "in free form");
320 else if (gfc_option.flag_d_lines == 1)
321 gfc_warning_now ("'-fd-lines-as-code' has no effect in free form");
324 /* If -pedantic, warn about the use of GNU extensions. */
325 if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0)
326 gfc_option.warn_std |= GFC_STD_GNU;
327 /* -std=legacy -pedantic is effectively -std=gnu. */
328 if (pedantic && (gfc_option.allow_std & GFC_STD_LEGACY) != 0)
329 gfc_option.warn_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_LEGACY;
331 /* If the user didn't explicitly specify -f(no)-second-underscore we
332 use it if we're trying to be compatible with f2c, and not
333 otherwise. */
334 if (gfc_option.flag_second_underscore == -1)
335 gfc_option.flag_second_underscore = gfc_option.flag_f2c;
337 if (!gfc_option.flag_automatic && gfc_option.flag_max_stack_var_size != -2
338 && gfc_option.flag_max_stack_var_size != 0)
339 gfc_warning_now ("Flag -fno-automatic overwrites -fmax-stack-var-size=%d",
340 gfc_option.flag_max_stack_var_size);
341 else if (!gfc_option.flag_automatic && gfc_option.flag_recursive)
342 gfc_warning_now ("Flag -fno-automatic overwrites -frecursive");
343 else if (!gfc_option.flag_automatic && gfc_option.flag_openmp)
344 gfc_warning_now ("Flag -fno-automatic overwrites -frecursive implied by "
345 "-fopenmp");
346 else if (gfc_option.flag_max_stack_var_size != -2
347 && gfc_option.flag_recursive)
348 gfc_warning_now ("Flag -frecursive overwrites -fmax-stack-var-size=%d",
349 gfc_option.flag_max_stack_var_size);
350 else if (gfc_option.flag_max_stack_var_size != -2
351 && gfc_option.flag_openmp)
352 gfc_warning_now ("Flag -fmax-stack-var-size=%d overwrites -frecursive "
353 "implied by -fopenmp",
354 gfc_option.flag_max_stack_var_size);
356 /* Implement -frecursive as -fmax-stack-var-size=-1. */
357 if (gfc_option.flag_recursive)
358 gfc_option.flag_max_stack_var_size = -1;
360 /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
361 if (gfc_option.flag_max_stack_var_size == -2 && gfc_option.flag_openmp
362 && gfc_option.flag_automatic)
364 gfc_option.flag_recursive = 1;
365 gfc_option.flag_max_stack_var_size = -1;
368 /* Set default. */
369 if (gfc_option.flag_max_stack_var_size == -2)
370 gfc_option.flag_max_stack_var_size = 32768;
372 /* Implement -fno-automatic as -fmax-stack-var-size=0. */
373 if (!gfc_option.flag_automatic)
374 gfc_option.flag_max_stack_var_size = 0;
376 if (pedantic)
378 gfc_option.warn_ampersand = 1;
379 gfc_option.warn_tabs = 0;
382 if (pedantic && gfc_option.flag_whole_file)
383 gfc_option.flag_whole_file = 2;
385 gfc_cpp_post_options ();
387 /* FIXME: return gfc_cpp_preprocess_only ();
389 The return value of this function indicates whether the
390 backend needs to be initialized. On -E, we don't need
391 the backend. However, if we return 'true' here, an
392 ICE occurs. Initializing the backend doesn't hurt much,
393 hence, for now we can live with it as is. */
394 return false;
398 /* Set the options for -Wall. */
400 static void
401 set_Wall (int setting)
403 gfc_option.warn_aliasing = setting;
404 gfc_option.warn_ampersand = setting;
405 gfc_option.warn_line_truncation = setting;
406 gfc_option.warn_surprising = setting;
407 gfc_option.warn_tabs = !setting;
408 gfc_option.warn_underflow = setting;
409 gfc_option.warn_intrinsic_shadow = setting;
410 gfc_option.warn_intrinsics_std = setting;
411 gfc_option.warn_character_truncation = setting;
413 warn_unused = setting;
414 warn_return_type = setting;
415 warn_switch = setting;
417 /* We save the value of warn_uninitialized, since if they put
418 -Wuninitialized on the command line, we need to generate a
419 warning about not using it without also specifying -O. */
420 if (setting == 0)
421 warn_uninitialized = 0;
422 else if (warn_uninitialized != 1)
423 warn_uninitialized = 2;
427 static void
428 gfc_handle_module_path_options (const char *arg)
431 if (gfc_option.module_dir != NULL)
432 gfc_fatal_error ("gfortran: Only one -J option allowed");
434 gfc_option.module_dir = (char *) gfc_getmem (strlen (arg) + 2);
435 strcpy (gfc_option.module_dir, arg);
436 strcat (gfc_option.module_dir, "/");
438 gfc_add_include_path (gfc_option.module_dir, true, false);
442 static void
443 gfc_handle_fpe_trap_option (const char *arg)
445 int result, pos = 0, n;
446 static const char * const exception[] = { "invalid", "denormal", "zero",
447 "overflow", "underflow",
448 "precision", NULL };
449 static const int opt_exception[] = { GFC_FPE_INVALID, GFC_FPE_DENORMAL,
450 GFC_FPE_ZERO, GFC_FPE_OVERFLOW,
451 GFC_FPE_UNDERFLOW, GFC_FPE_PRECISION,
452 0 };
454 while (*arg)
456 while (*arg == ',')
457 arg++;
459 while (arg[pos] && arg[pos] != ',')
460 pos++;
462 result = 0;
463 for (n = 0; exception[n] != NULL; n++)
465 if (exception[n] && strncmp (exception[n], arg, pos) == 0)
467 gfc_option.fpe |= opt_exception[n];
468 arg += pos;
469 pos = 0;
470 result = 1;
471 break;
474 if (!result)
475 gfc_fatal_error ("Argument to -ffpe-trap is not valid: %s", arg);
480 static void
481 gfc_handle_runtime_check_option (const char *arg)
483 int result, pos = 0, n;
484 static const char * const optname[] = { "all", "bounds", "array-temps",
485 "recursion", "do", "pointer", NULL };
486 static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS,
487 GFC_RTCHECK_ARRAY_TEMPS,
488 GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO,
489 GFC_RTCHECK_POINTER,
490 0 };
492 while (*arg)
494 while (*arg == ',')
495 arg++;
497 while (arg[pos] && arg[pos] != ',')
498 pos++;
500 result = 0;
501 for (n = 0; optname[n] != NULL; n++)
503 if (optname[n] && strncmp (optname[n], arg, pos) == 0)
505 gfc_option.rtcheck |= optmask[n];
506 arg += pos;
507 pos = 0;
508 result = 1;
509 break;
512 if (!result)
513 gfc_fatal_error ("Argument to -fcheck is not valid: %s", arg);
518 /* Handle command-line options. Returns 0 if unrecognized, 1 if
519 recognized and handled. */
522 gfc_handle_option (size_t scode, const char *arg, int value)
524 int result = 1;
525 enum opt_code code = (enum opt_code) scode;
527 /* Ignore file names. */
528 if (code == N_OPTS)
529 return 1;
531 if (gfc_cpp_handle_option (scode, arg, value) == 1)
532 return 1;
534 switch (code)
536 default:
537 result = 0;
538 break;
540 case OPT_Wall:
541 set_Wall (value);
542 break;
544 case OPT_Waliasing:
545 gfc_option.warn_aliasing = value;
546 break;
548 case OPT_Wampersand:
549 gfc_option.warn_ampersand = value;
550 break;
552 case OPT_Warray_temporaries:
553 gfc_option.warn_array_temp = value;
554 break;
556 case OPT_Wcharacter_truncation:
557 gfc_option.warn_character_truncation = value;
558 break;
560 case OPT_Wconversion:
561 gfc_option.warn_conversion = value;
562 break;
564 case OPT_Wimplicit_interface:
565 gfc_option.warn_implicit_interface = value;
566 break;
568 case OPT_Wimplicit_procedure:
569 gfc_option.warn_implicit_procedure = value;
570 break;
572 case OPT_Wline_truncation:
573 gfc_option.warn_line_truncation = value;
574 break;
576 case OPT_Wreturn_type:
577 warn_return_type = value;
578 break;
580 case OPT_Wsurprising:
581 gfc_option.warn_surprising = value;
582 break;
584 case OPT_Wtabs:
585 gfc_option.warn_tabs = value;
586 break;
588 case OPT_Wunderflow:
589 gfc_option.warn_underflow = value;
590 break;
592 case OPT_Wintrinsic_shadow:
593 gfc_option.warn_intrinsic_shadow = value;
594 break;
596 case OPT_Walign_commons:
597 gfc_option.warn_align_commons = value;
598 break;
600 case OPT_fall_intrinsics:
601 gfc_option.flag_all_intrinsics = 1;
602 break;
604 case OPT_fautomatic:
605 gfc_option.flag_automatic = value;
606 break;
608 case OPT_fallow_leading_underscore:
609 gfc_option.flag_allow_leading_underscore = value;
610 break;
612 case OPT_fbackslash:
613 gfc_option.flag_backslash = value;
614 break;
616 case OPT_fbacktrace:
617 gfc_option.flag_backtrace = value;
618 break;
620 case OPT_fcheck_array_temporaries:
621 gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS;
622 break;
624 case OPT_fdump_core:
625 gfc_option.flag_dump_core = value;
626 break;
628 case OPT_fcray_pointer:
629 gfc_option.flag_cray_pointer = value;
630 break;
632 case OPT_ff2c:
633 gfc_option.flag_f2c = value;
634 break;
636 case OPT_fdollar_ok:
637 gfc_option.flag_dollar_ok = value;
638 break;
640 case OPT_fexternal_blas:
641 gfc_option.flag_external_blas = value;
642 break;
644 case OPT_fblas_matmul_limit_:
645 gfc_option.blas_matmul_limit = value;
646 break;
648 case OPT_fd_lines_as_code:
649 gfc_option.flag_d_lines = 1;
650 break;
652 case OPT_fd_lines_as_comments:
653 gfc_option.flag_d_lines = 0;
654 break;
656 case OPT_fdump_parse_tree:
657 gfc_option.dump_parse_tree = value;
658 break;
660 case OPT_ffixed_form:
661 gfc_option.source_form = FORM_FIXED;
662 break;
664 case OPT_ffixed_line_length_none:
665 gfc_option.fixed_line_length = 0;
666 break;
668 case OPT_ffixed_line_length_:
669 if (value != 0 && value < 7)
670 gfc_fatal_error ("Fixed line length must be at least seven.");
671 gfc_option.fixed_line_length = value;
672 break;
674 case OPT_ffree_form:
675 gfc_option.source_form = FORM_FREE;
676 break;
678 case OPT_fopenmp:
679 gfc_option.flag_openmp = value;
680 break;
682 case OPT_ffree_line_length_none:
683 gfc_option.free_line_length = 0;
684 break;
686 case OPT_ffree_line_length_:
687 if (value != 0 && value < 4)
688 gfc_fatal_error ("Free line length must be at least three.");
689 gfc_option.free_line_length = value;
690 break;
692 case OPT_funderscoring:
693 gfc_option.flag_underscoring = value;
694 break;
696 case OPT_fwhole_file:
697 gfc_option.flag_whole_file = 1;
698 break;
700 case OPT_fsecond_underscore:
701 gfc_option.flag_second_underscore = value;
702 break;
704 case OPT_static_libgfortran:
705 #ifndef HAVE_LD_STATIC_DYNAMIC
706 gfc_fatal_error ("-static-libgfortran is not supported in this "
707 "configuration");
708 #endif
709 break;
711 case OPT_fimplicit_none:
712 gfc_option.flag_implicit_none = value;
713 break;
715 case OPT_fintrinsic_modules_path:
716 gfc_add_include_path (arg, false, false);
717 gfc_add_intrinsic_modules_path (arg);
718 break;
720 case OPT_fmax_array_constructor_:
721 gfc_option.flag_max_array_constructor = value > 65535 ? value : 65535;
722 break;
724 case OPT_fmax_errors_:
725 gfc_option.max_errors = value;
726 break;
728 case OPT_fmax_stack_var_size_:
729 gfc_option.flag_max_stack_var_size = value;
730 break;
732 case OPT_fmodule_private:
733 gfc_option.flag_module_private = value;
734 break;
736 case OPT_frange_check:
737 gfc_option.flag_range_check = value;
738 break;
740 case OPT_fpack_derived:
741 gfc_option.flag_pack_derived = value;
742 break;
744 case OPT_frepack_arrays:
745 gfc_option.flag_repack_arrays = value;
746 break;
748 case OPT_fpreprocessed:
749 gfc_option.flag_preprocessed = value;
750 break;
752 case OPT_fmax_identifier_length_:
753 if (value > GFC_MAX_SYMBOL_LEN)
754 gfc_fatal_error ("Maximum supported identifier length is %d",
755 GFC_MAX_SYMBOL_LEN);
756 gfc_option.max_identifier_length = value;
757 break;
759 case OPT_fdefault_integer_8:
760 gfc_option.flag_default_integer = value;
761 break;
763 case OPT_fdefault_real_8:
764 gfc_option.flag_default_real = value;
765 break;
767 case OPT_fdefault_double_8:
768 gfc_option.flag_default_double = value;
769 break;
771 case OPT_finit_local_zero:
772 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
773 gfc_option.flag_init_integer_value = 0;
774 gfc_option.flag_init_real = GFC_INIT_REAL_ZERO;
775 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
776 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
777 gfc_option.flag_init_character_value = (char)0;
778 break;
780 case OPT_finit_logical_:
781 if (!strcasecmp (arg, "false"))
782 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
783 else if (!strcasecmp (arg, "true"))
784 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_TRUE;
785 else
786 gfc_fatal_error ("Unrecognized option to -finit-logical: %s",
787 arg);
788 break;
790 case OPT_finit_real_:
791 if (!strcasecmp (arg, "zero"))
792 gfc_option.flag_init_real = GFC_INIT_REAL_ZERO;
793 else if (!strcasecmp (arg, "nan"))
794 gfc_option.flag_init_real = GFC_INIT_REAL_NAN;
795 else if (!strcasecmp (arg, "snan"))
796 gfc_option.flag_init_real = GFC_INIT_REAL_SNAN;
797 else if (!strcasecmp (arg, "inf"))
798 gfc_option.flag_init_real = GFC_INIT_REAL_INF;
799 else if (!strcasecmp (arg, "-inf"))
800 gfc_option.flag_init_real = GFC_INIT_REAL_NEG_INF;
801 else
802 gfc_fatal_error ("Unrecognized option to -finit-real: %s",
803 arg);
804 break;
806 case OPT_finit_integer_:
807 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
808 gfc_option.flag_init_integer_value = atoi (arg);
809 break;
811 case OPT_finit_character_:
812 if (value >= 0 && value <= 127)
814 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
815 gfc_option.flag_init_character_value = (char)value;
817 else
818 gfc_fatal_error ("The value of n in -finit-character=n must be "
819 "between 0 and 127");
820 break;
822 case OPT_I:
823 gfc_add_include_path (arg, true, false);
824 break;
826 case OPT_J:
827 gfc_handle_module_path_options (arg);
828 break;
830 case OPT_fsign_zero:
831 gfc_option.flag_sign_zero = value;
832 break;
834 case OPT_ffpe_trap_:
835 gfc_handle_fpe_trap_option (arg);
836 break;
838 case OPT_std_f95:
839 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77;
840 gfc_option.warn_std = GFC_STD_F95_OBS;
841 gfc_option.max_continue_fixed = 19;
842 gfc_option.max_continue_free = 39;
843 gfc_option.max_identifier_length = 31;
844 gfc_option.warn_ampersand = 1;
845 gfc_option.warn_tabs = 0;
846 break;
848 case OPT_std_f2003:
849 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
850 | GFC_STD_F2003 | GFC_STD_F95;
851 gfc_option.warn_std = GFC_STD_F95_OBS;
852 gfc_option.max_identifier_length = 63;
853 gfc_option.warn_ampersand = 1;
854 gfc_option.warn_tabs = 0;
855 break;
857 case OPT_std_f2008:
858 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
859 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008;
860 gfc_option.warn_std = GFC_STD_F95_OBS;
861 gfc_option.max_identifier_length = 63;
862 gfc_option.warn_ampersand = 1;
863 gfc_option.warn_tabs = 0;
864 break;
866 case OPT_std_gnu:
867 set_default_std_flags ();
868 break;
870 case OPT_std_legacy:
871 set_default_std_flags ();
872 gfc_option.warn_std = 0;
873 break;
875 case OPT_Wintrinsics_std:
876 gfc_option.warn_intrinsics_std = value;
877 break;
879 case OPT_fshort_enums:
880 flag_short_enums = 1;
881 break;
883 case OPT_fconvert_little_endian:
884 gfc_option.convert = GFC_CONVERT_LITTLE;
885 break;
887 case OPT_fconvert_big_endian:
888 gfc_option.convert = GFC_CONVERT_BIG;
889 break;
891 case OPT_fconvert_native:
892 gfc_option.convert = GFC_CONVERT_NATIVE;
893 break;
895 case OPT_fconvert_swap:
896 gfc_option.convert = GFC_CONVERT_SWAP;
897 break;
899 case OPT_frecord_marker_4:
900 gfc_option.record_marker = 4;
901 break;
903 case OPT_frecord_marker_8:
904 gfc_option.record_marker = 8;
905 break;
907 case OPT_fmax_subrecord_length_:
908 if (value > MAX_SUBRECORD_LENGTH)
909 gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
910 MAX_SUBRECORD_LENGTH);
912 gfc_option.max_subrecord_length = value;
913 break;
915 case OPT_frecursive:
916 gfc_option.flag_recursive = 1;
917 break;
919 case OPT_falign_commons:
920 gfc_option.flag_align_commons = value;
921 break;
923 case OPT_fcheck_:
924 gfc_handle_runtime_check_option (arg);
925 break;
929 return result;