* passes.c (init_optimization_passes): Remove two copies of ehcleanup
[official-gcc/constexpr.git] / gcc / fortran / options.c
blobb45696ddf356a8d87d393314e0993f7bd087f1be
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 gfc_option.fshort_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 /* Issue an error if -fwhole-program was used. */
242 if (flag_whole_program)
243 gfc_fatal_error ("Option -fwhole-program is not supported for Fortran");
245 /* -fbounds-check is equivalent to -fcheck=bounds */
246 if (flag_bounds_check)
247 gfc_option.rtcheck |= GFC_RTCHECK_BOUNDS;
249 /* Verify the input file name. */
250 if (!filename || strcmp (filename, "-") == 0)
252 filename = "";
255 if (gfc_option.flag_preprocessed)
257 /* For preprocessed files, if the first tokens are of the form # NUM.
258 handle the directives so we know the original file name. */
259 gfc_source_file = gfc_read_orig_filename (filename, &canon_source_file);
260 if (gfc_source_file == NULL)
261 gfc_source_file = filename;
262 else
263 *pfilename = gfc_source_file;
265 else
266 gfc_source_file = filename;
268 if (canon_source_file == NULL)
269 canon_source_file = gfc_source_file;
271 /* Adds the path where the source file is to the list of include files. */
273 i = strlen (canon_source_file);
274 while (i > 0 && !IS_DIR_SEPARATOR (canon_source_file[i]))
275 i--;
277 if (i != 0)
279 source_path = (char *) alloca (i + 1);
280 memcpy (source_path, canon_source_file, i);
281 source_path[i] = 0;
282 gfc_add_include_path (source_path, true, true);
284 else
285 gfc_add_include_path (".", true, true);
287 if (canon_source_file != gfc_source_file)
288 gfc_free (CONST_CAST (char *, canon_source_file));
290 /* Decide which form the file will be read in as. */
292 if (gfc_option.source_form != FORM_UNKNOWN)
293 gfc_current_form = gfc_option.source_form;
294 else
296 gfc_current_form = form_from_filename (filename);
298 if (gfc_current_form == FORM_UNKNOWN)
300 gfc_current_form = FORM_FREE;
301 gfc_warning_now ("Reading file '%s' as free form",
302 (filename[0] == '\0') ? "<stdin>" : filename);
306 /* If the user specified -fd-lines-as-{code|comments} verify that we're
307 in fixed form. */
308 if (gfc_current_form == FORM_FREE)
310 if (gfc_option.flag_d_lines == 0)
311 gfc_warning_now ("'-fd-lines-as-comments' has no effect "
312 "in free form");
313 else if (gfc_option.flag_d_lines == 1)
314 gfc_warning_now ("'-fd-lines-as-code' has no effect in free form");
317 /* If -pedantic, warn about the use of GNU extensions. */
318 if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0)
319 gfc_option.warn_std |= GFC_STD_GNU;
320 /* -std=legacy -pedantic is effectively -std=gnu. */
321 if (pedantic && (gfc_option.allow_std & GFC_STD_LEGACY) != 0)
322 gfc_option.warn_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_LEGACY;
324 /* If the user didn't explicitly specify -f(no)-second-underscore we
325 use it if we're trying to be compatible with f2c, and not
326 otherwise. */
327 if (gfc_option.flag_second_underscore == -1)
328 gfc_option.flag_second_underscore = gfc_option.flag_f2c;
330 if (!gfc_option.flag_automatic && gfc_option.flag_max_stack_var_size != -2
331 && gfc_option.flag_max_stack_var_size != 0)
332 gfc_warning_now ("Flag -fno-automatic overwrites -fmax-stack-var-size=%d",
333 gfc_option.flag_max_stack_var_size);
334 else if (!gfc_option.flag_automatic && gfc_option.flag_recursive)
335 gfc_warning_now ("Flag -fno-automatic overwrites -frecursive");
336 else if (!gfc_option.flag_automatic && gfc_option.flag_openmp)
337 gfc_warning_now ("Flag -fno-automatic overwrites -frecursive implied by "
338 "-fopenmp");
339 else if (gfc_option.flag_max_stack_var_size != -2
340 && gfc_option.flag_recursive)
341 gfc_warning_now ("Flag -frecursive overwrites -fmax-stack-var-size=%d",
342 gfc_option.flag_max_stack_var_size);
343 else if (gfc_option.flag_max_stack_var_size != -2
344 && gfc_option.flag_openmp)
345 gfc_warning_now ("Flag -fmax-stack-var-size=%d overwrites -frecursive "
346 "implied by -fopenmp",
347 gfc_option.flag_max_stack_var_size);
349 /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
350 if (gfc_option.flag_max_stack_var_size == -2 && gfc_option.flag_openmp)
351 gfc_option.flag_max_stack_var_size = -1;
353 /* Set default. */
354 if (gfc_option.flag_max_stack_var_size == -2)
355 gfc_option.flag_max_stack_var_size = 32768;
357 /* Implement -frecursive as -fmax-stack-var-size=-1. */
358 if (gfc_option.flag_recursive)
359 gfc_option.flag_max_stack_var_size = -1;
361 /* Implement -fno-automatic as -fmax-stack-var-size=0. */
362 if (!gfc_option.flag_automatic)
363 gfc_option.flag_max_stack_var_size = 0;
365 if (pedantic)
367 gfc_option.warn_ampersand = 1;
368 gfc_option.warn_tabs = 0;
371 gfc_cpp_post_options ();
373 /* FIXME: return gfc_cpp_preprocess_only ();
375 The return value of this function indicates whether the
376 backend needs to be initialized. On -E, we don't need
377 the backend. However, if we return 'true' here, an
378 ICE occurs. Initializing the backend doesn't hurt much,
379 hence, for now we can live with it as is. */
380 return false;
384 /* Set the options for -Wall. */
386 static void
387 set_Wall (int setting)
389 gfc_option.warn_aliasing = setting;
390 gfc_option.warn_ampersand = setting;
391 gfc_option.warn_line_truncation = setting;
392 gfc_option.warn_surprising = setting;
393 gfc_option.warn_tabs = !setting;
394 gfc_option.warn_underflow = setting;
395 gfc_option.warn_intrinsic_shadow = setting;
396 gfc_option.warn_intrinsics_std = setting;
397 gfc_option.warn_character_truncation = setting;
399 warn_unused = setting;
400 warn_return_type = setting;
401 warn_switch = setting;
403 /* We save the value of warn_uninitialized, since if they put
404 -Wuninitialized on the command line, we need to generate a
405 warning about not using it without also specifying -O. */
406 if (setting == 0)
407 warn_uninitialized = 0;
408 else if (warn_uninitialized != 1)
409 warn_uninitialized = 2;
413 static void
414 gfc_handle_module_path_options (const char *arg)
417 if (gfc_option.module_dir != NULL)
418 gfc_fatal_error ("gfortran: Only one -J option allowed");
420 gfc_option.module_dir = (char *) gfc_getmem (strlen (arg) + 2);
421 strcpy (gfc_option.module_dir, arg);
422 strcat (gfc_option.module_dir, "/");
424 gfc_add_include_path (gfc_option.module_dir, true, false);
428 static void
429 gfc_handle_fpe_trap_option (const char *arg)
431 int result, pos = 0, n;
432 static const char * const exception[] = { "invalid", "denormal", "zero",
433 "overflow", "underflow",
434 "precision", NULL };
435 static const int opt_exception[] = { GFC_FPE_INVALID, GFC_FPE_DENORMAL,
436 GFC_FPE_ZERO, GFC_FPE_OVERFLOW,
437 GFC_FPE_UNDERFLOW, GFC_FPE_PRECISION,
438 0 };
440 while (*arg)
442 while (*arg == ',')
443 arg++;
445 while (arg[pos] && arg[pos] != ',')
446 pos++;
448 result = 0;
449 for (n = 0; exception[n] != NULL; n++)
451 if (exception[n] && strncmp (exception[n], arg, pos) == 0)
453 gfc_option.fpe |= opt_exception[n];
454 arg += pos;
455 pos = 0;
456 result = 1;
457 break;
460 if (!result)
461 gfc_fatal_error ("Argument to -ffpe-trap is not valid: %s", arg);
466 static void
467 gfc_handle_runtime_check_option (const char *arg)
469 int result, pos = 0, n;
470 static const char * const optname[] = { "all", "bounds", "array-temps",
471 "recursion", "do", NULL };
472 static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS,
473 GFC_RTCHECK_ARRAY_TEMPS,
474 GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO,
475 0 };
477 while (*arg)
479 while (*arg == ',')
480 arg++;
482 while (arg[pos] && arg[pos] != ',')
483 pos++;
485 result = 0;
486 for (n = 0; optname[n] != NULL; n++)
488 if (optname[n] && strncmp (optname[n], arg, pos) == 0)
490 gfc_option.rtcheck |= optmask[n];
491 arg += pos;
492 pos = 0;
493 result = 1;
494 break;
497 if (!result)
498 gfc_fatal_error ("Argument to -fcheck is not valid: %s", arg);
503 /* Handle command-line options. Returns 0 if unrecognized, 1 if
504 recognized and handled. */
507 gfc_handle_option (size_t scode, const char *arg, int value)
509 int result = 1;
510 enum opt_code code = (enum opt_code) scode;
512 /* Ignore file names. */
513 if (code == N_OPTS)
514 return 1;
516 if (gfc_cpp_handle_option (scode, arg, value) == 1)
517 return 1;
519 switch (code)
521 default:
522 result = 0;
523 break;
525 case OPT_Wall:
526 set_Wall (value);
527 break;
529 case OPT_Waliasing:
530 gfc_option.warn_aliasing = value;
531 break;
533 case OPT_Wampersand:
534 gfc_option.warn_ampersand = value;
535 break;
537 case OPT_Warray_temporaries:
538 gfc_option.warn_array_temp = value;
539 break;
541 case OPT_Wcharacter_truncation:
542 gfc_option.warn_character_truncation = value;
543 break;
545 case OPT_Wconversion:
546 gfc_option.warn_conversion = value;
547 break;
549 case OPT_Wimplicit_interface:
550 gfc_option.warn_implicit_interface = value;
551 break;
553 case OPT_Wline_truncation:
554 gfc_option.warn_line_truncation = value;
555 break;
557 case OPT_Wreturn_type:
558 warn_return_type = value;
559 break;
561 case OPT_Wsurprising:
562 gfc_option.warn_surprising = value;
563 break;
565 case OPT_Wtabs:
566 gfc_option.warn_tabs = value;
567 break;
569 case OPT_Wunderflow:
570 gfc_option.warn_underflow = value;
571 break;
573 case OPT_Wintrinsic_shadow:
574 gfc_option.warn_intrinsic_shadow = value;
575 break;
577 case OPT_Walign_commons:
578 gfc_option.warn_align_commons = value;
579 break;
581 case OPT_fall_intrinsics:
582 gfc_option.flag_all_intrinsics = 1;
583 break;
585 case OPT_fautomatic:
586 gfc_option.flag_automatic = value;
587 break;
589 case OPT_fallow_leading_underscore:
590 gfc_option.flag_allow_leading_underscore = value;
591 break;
593 case OPT_fbackslash:
594 gfc_option.flag_backslash = value;
595 break;
597 case OPT_fbacktrace:
598 gfc_option.flag_backtrace = value;
599 break;
601 case OPT_fcheck_array_temporaries:
602 gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS;
603 break;
605 case OPT_fdump_core:
606 gfc_option.flag_dump_core = value;
607 break;
609 case OPT_fcray_pointer:
610 gfc_option.flag_cray_pointer = value;
611 break;
613 case OPT_ff2c:
614 gfc_option.flag_f2c = value;
615 break;
617 case OPT_fdollar_ok:
618 gfc_option.flag_dollar_ok = value;
619 break;
621 case OPT_fexternal_blas:
622 gfc_option.flag_external_blas = value;
623 break;
625 case OPT_fblas_matmul_limit_:
626 gfc_option.blas_matmul_limit = value;
627 break;
629 case OPT_fd_lines_as_code:
630 gfc_option.flag_d_lines = 1;
631 break;
633 case OPT_fd_lines_as_comments:
634 gfc_option.flag_d_lines = 0;
635 break;
637 case OPT_fdump_parse_tree:
638 gfc_option.dump_parse_tree = value;
639 break;
641 case OPT_ffixed_form:
642 gfc_option.source_form = FORM_FIXED;
643 break;
645 case OPT_ffixed_line_length_none:
646 gfc_option.fixed_line_length = 0;
647 break;
649 case OPT_ffixed_line_length_:
650 if (value != 0 && value < 7)
651 gfc_fatal_error ("Fixed line length must be at least seven.");
652 gfc_option.fixed_line_length = value;
653 break;
655 case OPT_ffree_form:
656 gfc_option.source_form = FORM_FREE;
657 break;
659 case OPT_fopenmp:
660 gfc_option.flag_openmp = value;
661 break;
663 case OPT_ffree_line_length_none:
664 gfc_option.free_line_length = 0;
665 break;
667 case OPT_ffree_line_length_:
668 if (value != 0 && value < 4)
669 gfc_fatal_error ("Free line length must be at least three.");
670 gfc_option.free_line_length = value;
671 break;
673 case OPT_funderscoring:
674 gfc_option.flag_underscoring = value;
675 break;
677 case OPT_fwhole_file:
678 gfc_option.flag_whole_file = 1;
679 break;
681 case OPT_fsecond_underscore:
682 gfc_option.flag_second_underscore = value;
683 break;
685 case OPT_static_libgfortran:
686 #ifndef HAVE_LD_STATIC_DYNAMIC
687 gfc_fatal_error ("-static-libgfortran is not supported in this "
688 "configuration");
689 #endif
690 break;
692 case OPT_fimplicit_none:
693 gfc_option.flag_implicit_none = value;
694 break;
696 case OPT_fintrinsic_modules_path:
697 gfc_add_include_path (arg, false, false);
698 gfc_add_intrinsic_modules_path (arg);
699 break;
701 case OPT_fmax_array_constructor_:
702 gfc_option.flag_max_array_constructor = value > 65535 ? value : 65535;
703 break;
705 case OPT_fmax_errors_:
706 gfc_option.max_errors = value;
707 break;
709 case OPT_fmax_stack_var_size_:
710 gfc_option.flag_max_stack_var_size = value;
711 break;
713 case OPT_fmodule_private:
714 gfc_option.flag_module_private = value;
715 break;
717 case OPT_frange_check:
718 gfc_option.flag_range_check = value;
719 break;
721 case OPT_fpack_derived:
722 gfc_option.flag_pack_derived = value;
723 break;
725 case OPT_frepack_arrays:
726 gfc_option.flag_repack_arrays = value;
727 break;
729 case OPT_fpreprocessed:
730 gfc_option.flag_preprocessed = value;
731 break;
733 case OPT_fmax_identifier_length_:
734 if (value > GFC_MAX_SYMBOL_LEN)
735 gfc_fatal_error ("Maximum supported identifier length is %d",
736 GFC_MAX_SYMBOL_LEN);
737 gfc_option.max_identifier_length = value;
738 break;
740 case OPT_fdefault_integer_8:
741 gfc_option.flag_default_integer = value;
742 break;
744 case OPT_fdefault_real_8:
745 gfc_option.flag_default_real = value;
746 break;
748 case OPT_fdefault_double_8:
749 gfc_option.flag_default_double = value;
750 break;
752 case OPT_finit_local_zero:
753 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
754 gfc_option.flag_init_integer_value = 0;
755 gfc_option.flag_init_real = GFC_INIT_REAL_ZERO;
756 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
757 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
758 gfc_option.flag_init_character_value = (char)0;
759 break;
761 case OPT_finit_logical_:
762 if (!strcasecmp (arg, "false"))
763 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
764 else if (!strcasecmp (arg, "true"))
765 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_TRUE;
766 else
767 gfc_fatal_error ("Unrecognized option to -finit-logical: %s",
768 arg);
769 break;
771 case OPT_finit_real_:
772 if (!strcasecmp (arg, "zero"))
773 gfc_option.flag_init_real = GFC_INIT_REAL_ZERO;
774 else if (!strcasecmp (arg, "nan"))
775 gfc_option.flag_init_real = GFC_INIT_REAL_NAN;
776 else if (!strcasecmp (arg, "snan"))
777 gfc_option.flag_init_real = GFC_INIT_REAL_SNAN;
778 else if (!strcasecmp (arg, "inf"))
779 gfc_option.flag_init_real = GFC_INIT_REAL_INF;
780 else if (!strcasecmp (arg, "-inf"))
781 gfc_option.flag_init_real = GFC_INIT_REAL_NEG_INF;
782 else
783 gfc_fatal_error ("Unrecognized option to -finit-real: %s",
784 arg);
785 break;
787 case OPT_finit_integer_:
788 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
789 gfc_option.flag_init_integer_value = atoi (arg);
790 break;
792 case OPT_finit_character_:
793 if (value >= 0 && value <= 127)
795 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
796 gfc_option.flag_init_character_value = (char)value;
798 else
799 gfc_fatal_error ("The value of n in -finit-character=n must be "
800 "between 0 and 127");
801 break;
803 case OPT_I:
804 gfc_add_include_path (arg, true, false);
805 break;
807 case OPT_J:
808 gfc_handle_module_path_options (arg);
809 break;
811 case OPT_fsign_zero:
812 gfc_option.flag_sign_zero = value;
813 break;
815 case OPT_ffpe_trap_:
816 gfc_handle_fpe_trap_option (arg);
817 break;
819 case OPT_std_f95:
820 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77;
821 gfc_option.warn_std = GFC_STD_F95_OBS;
822 gfc_option.max_continue_fixed = 19;
823 gfc_option.max_continue_free = 39;
824 gfc_option.max_identifier_length = 31;
825 gfc_option.warn_ampersand = 1;
826 gfc_option.warn_tabs = 0;
827 break;
829 case OPT_std_f2003:
830 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
831 | GFC_STD_F2003 | GFC_STD_F95;
832 gfc_option.warn_std = GFC_STD_F95_OBS;
833 gfc_option.max_identifier_length = 63;
834 gfc_option.warn_ampersand = 1;
835 gfc_option.warn_tabs = 0;
836 break;
838 case OPT_std_f2008:
839 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
840 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008;
841 gfc_option.warn_std = GFC_STD_F95_OBS;
842 gfc_option.max_identifier_length = 63;
843 gfc_option.warn_ampersand = 1;
844 gfc_option.warn_tabs = 0;
845 break;
847 case OPT_std_gnu:
848 set_default_std_flags ();
849 break;
851 case OPT_std_legacy:
852 set_default_std_flags ();
853 gfc_option.warn_std = 0;
854 break;
856 case OPT_Wintrinsics_std:
857 gfc_option.warn_intrinsics_std = value;
858 break;
860 case OPT_fshort_enums:
861 gfc_option.fshort_enums = 1;
862 break;
864 case OPT_fconvert_little_endian:
865 gfc_option.convert = GFC_CONVERT_LITTLE;
866 break;
868 case OPT_fconvert_big_endian:
869 gfc_option.convert = GFC_CONVERT_BIG;
870 break;
872 case OPT_fconvert_native:
873 gfc_option.convert = GFC_CONVERT_NATIVE;
874 break;
876 case OPT_fconvert_swap:
877 gfc_option.convert = GFC_CONVERT_SWAP;
878 break;
880 case OPT_frecord_marker_4:
881 gfc_option.record_marker = 4;
882 break;
884 case OPT_frecord_marker_8:
885 gfc_option.record_marker = 8;
886 break;
888 case OPT_fmax_subrecord_length_:
889 if (value > MAX_SUBRECORD_LENGTH)
890 gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
891 MAX_SUBRECORD_LENGTH);
893 gfc_option.max_subrecord_length = value;
894 break;
896 case OPT_frecursive:
897 gfc_option.flag_recursive = 1;
898 break;
900 case OPT_falign_commons:
901 gfc_option.flag_align_commons = value;
902 break;
904 case OPT_fcheck_:
905 gfc_handle_runtime_check_option (arg);
906 break;
910 return result;