1 /* Parse and display command line options.
2 Copyright (C) 2000-2014 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
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
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/>. */
23 #include "coretypes.h"
28 #include "toplev.h" /* For save_decoded_options. */
31 #include "tree-inline.h"
35 #include "diagnostic.h" /* For global_dc. */
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). */
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_F2008_OBS
| GFC_STD_F2008_TS
| GFC_STD_GNU
| GFC_STD_LEGACY
;
51 gfc_option
.warn_std
= GFC_STD_F95_DEL
| GFC_STD_LEGACY
;
55 /* Return language mask for Fortran options. */
58 gfc_option_lang_mask (void)
63 /* Initialize options structure OPTS. */
66 gfc_init_options_struct (struct gcc_options
*opts
)
68 opts
->x_flag_errno_math
= 0;
69 opts
->frontend_set_flag_errno_math
= true;
70 opts
->x_flag_associative_math
= -1;
71 opts
->frontend_set_flag_associative_math
= true;
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
.max_errors
= 25;
98 gfc_option
.flag_all_intrinsics
= 0;
99 gfc_option
.flag_default_double
= 0;
100 gfc_option
.flag_default_integer
= 0;
101 gfc_option
.flag_default_real
= 0;
102 gfc_option
.flag_integer4_kind
= 0;
103 gfc_option
.flag_real4_kind
= 0;
104 gfc_option
.flag_real8_kind
= 0;
105 gfc_option
.flag_dollar_ok
= 0;
106 gfc_option
.flag_underscoring
= 1;
107 gfc_option
.flag_f2c
= 0;
108 gfc_option
.flag_second_underscore
= -1;
109 gfc_option
.flag_implicit_none
= 0;
111 /* Default value of flag_max_stack_var_size is set in gfc_post_options. */
112 gfc_option
.flag_max_stack_var_size
= -2;
113 gfc_option
.flag_stack_arrays
= -1;
115 gfc_option
.flag_range_check
= 1;
116 gfc_option
.flag_pack_derived
= 0;
117 gfc_option
.flag_repack_arrays
= 0;
118 gfc_option
.flag_preprocessed
= 0;
119 gfc_option
.flag_automatic
= 1;
120 gfc_option
.flag_backslash
= 0;
121 gfc_option
.flag_module_private
= 0;
122 gfc_option
.flag_backtrace
= 1;
123 gfc_option
.flag_allow_leading_underscore
= 0;
124 gfc_option
.flag_external_blas
= 0;
125 gfc_option
.blas_matmul_limit
= 30;
126 gfc_option
.flag_cray_pointer
= 0;
127 gfc_option
.flag_d_lines
= -1;
128 gfc_option
.gfc_flag_openmp
= 0;
129 gfc_option
.flag_sign_zero
= 1;
130 gfc_option
.flag_recursive
= 0;
131 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_OFF
;
132 gfc_option
.flag_init_integer_value
= 0;
133 gfc_option
.flag_init_real
= GFC_INIT_REAL_OFF
;
134 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_OFF
;
135 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_OFF
;
136 gfc_option
.flag_init_character_value
= (char)0;
137 gfc_option
.flag_align_commons
= 1;
138 gfc_option
.flag_protect_parens
= -1;
139 gfc_option
.flag_realloc_lhs
= -1;
140 gfc_option
.flag_aggressive_function_elimination
= 0;
141 gfc_option
.flag_frontend_optimize
= -1;
144 /* All except GFC_FPE_INEXACT. */
145 gfc_option
.fpe_summary
= GFC_FPE_INVALID
| GFC_FPE_DENORMAL
146 | GFC_FPE_ZERO
| GFC_FPE_OVERFLOW
148 gfc_option
.rtcheck
= 0;
149 gfc_option
.coarray
= GFC_FCOARRAY_NONE
;
151 /* ??? Wmissing-include-dirs is disabled by default in C/C++ but
152 enabled by default in Fortran. Ideally, we should express this
153 in .opt, but that is not supported yet. */
154 if (!global_options_set
.x_cpp_warn_missing_include_dirs
)
155 global_options
.x_cpp_warn_missing_include_dirs
= 1;;
157 set_default_std_flags ();
159 /* Initialize cpp-related options. */
160 gfc_cpp_init_options (decoded_options_count
, decoded_options
);
161 gfc_diagnostics_init ();
165 /* Determine the source form from the filename extension. We assume
166 case insensitivity. */
168 static gfc_source_form
169 form_from_filename (const char *filename
)
173 const char *extension
;
174 gfc_source_form form
;
201 }; /* sentinel value */
203 gfc_source_form f_form
;
207 /* Find end of file name. Note, filename is either a NULL pointer or
208 a NUL terminated string. */
210 while (filename
[i
] != '\0')
213 /* Find last period. */
214 while (i
>= 0 && (filename
[i
] != '.'))
217 /* Did we see a file extension? */
219 return FORM_UNKNOWN
; /* Nope */
221 /* Get file extension and compare it to others. */
222 fileext
= &(filename
[i
]);
225 f_form
= FORM_UNKNOWN
;
229 if (strcasecmp (fileext
, exttype
[i
].extension
) == 0)
231 f_form
= exttype
[i
].form
;
235 while (exttype
[i
].form
!= FORM_UNKNOWN
);
241 /* Finalize commandline options. */
244 gfc_post_options (const char **pfilename
)
246 const char *filename
= *pfilename
, *canon_source_file
= NULL
;
250 /* Excess precision other than "fast" requires front-end
252 if (flag_excess_precision_cmdline
== EXCESS_PRECISION_STANDARD
253 && TARGET_FLT_EVAL_METHOD_NON_DEFAULT
)
254 sorry ("-fexcess-precision=standard for Fortran");
255 flag_excess_precision_cmdline
= EXCESS_PRECISION_FAST
;
257 /* Fortran allows associative math - but we cannot reassociate if
258 we want traps or signed zeros. Cf. also flag_protect_parens. */
259 if (flag_associative_math
== -1)
260 flag_associative_math
= (!flag_trapping_math
&& !flag_signed_zeros
);
262 if (gfc_option
.flag_protect_parens
== -1)
263 gfc_option
.flag_protect_parens
= !optimize_fast
;
265 if (gfc_option
.flag_stack_arrays
== -1)
266 gfc_option
.flag_stack_arrays
= optimize_fast
;
268 /* By default, disable (re)allocation during assignment for -std=f95,
269 and enable it for F2003/F2008/GNU/Legacy. */
270 if (gfc_option
.flag_realloc_lhs
== -1)
272 if (gfc_option
.allow_std
& GFC_STD_F2003
)
273 gfc_option
.flag_realloc_lhs
= 1;
275 gfc_option
.flag_realloc_lhs
= 0;
278 /* -fbounds-check is equivalent to -fcheck=bounds */
279 if (flag_bounds_check
)
280 gfc_option
.rtcheck
|= GFC_RTCHECK_BOUNDS
;
282 if (flag_compare_debug
)
283 gfc_option
.dump_fortran_original
= 0;
285 /* Make -fmax-errors visible to gfortran's diagnostic machinery. */
286 if (global_options_set
.x_flag_max_errors
)
287 gfc_option
.max_errors
= flag_max_errors
;
289 /* Verify the input file name. */
290 if (!filename
|| strcmp (filename
, "-") == 0)
295 if (gfc_option
.flag_preprocessed
)
297 /* For preprocessed files, if the first tokens are of the form # NUM.
298 handle the directives so we know the original file name. */
299 gfc_source_file
= gfc_read_orig_filename (filename
, &canon_source_file
);
300 if (gfc_source_file
== NULL
)
301 gfc_source_file
= filename
;
303 *pfilename
= gfc_source_file
;
306 gfc_source_file
= filename
;
308 if (canon_source_file
== NULL
)
309 canon_source_file
= gfc_source_file
;
311 /* Adds the path where the source file is to the list of include files. */
313 i
= strlen (canon_source_file
);
314 while (i
> 0 && !IS_DIR_SEPARATOR (canon_source_file
[i
]))
319 source_path
= (char *) alloca (i
+ 1);
320 memcpy (source_path
, canon_source_file
, i
);
322 gfc_add_include_path (source_path
, true, true, true);
325 gfc_add_include_path (".", true, true, true);
327 if (canon_source_file
!= gfc_source_file
)
328 free (CONST_CAST (char *, canon_source_file
));
330 /* Decide which form the file will be read in as. */
332 if (gfc_option
.source_form
!= FORM_UNKNOWN
)
333 gfc_current_form
= gfc_option
.source_form
;
336 gfc_current_form
= form_from_filename (filename
);
338 if (gfc_current_form
== FORM_UNKNOWN
)
340 gfc_current_form
= FORM_FREE
;
341 gfc_warning_now ("Reading file %qs as free form",
342 (filename
[0] == '\0') ? "<stdin>" : filename
);
346 /* If the user specified -fd-lines-as-{code|comments} verify that we're
348 if (gfc_current_form
== FORM_FREE
)
350 if (gfc_option
.flag_d_lines
== 0)
351 gfc_warning_now ("%<-fd-lines-as-comments%> has no effect "
353 else if (gfc_option
.flag_d_lines
== 1)
354 gfc_warning_now ("%<-fd-lines-as-code%> has no effect in free form");
357 /* If -pedantic, warn about the use of GNU extensions. */
358 if (pedantic
&& (gfc_option
.allow_std
& GFC_STD_GNU
) != 0)
359 gfc_option
.warn_std
|= GFC_STD_GNU
;
360 /* -std=legacy -pedantic is effectively -std=gnu. */
361 if (pedantic
&& (gfc_option
.allow_std
& GFC_STD_LEGACY
) != 0)
362 gfc_option
.warn_std
|= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
| GFC_STD_LEGACY
;
364 /* If the user didn't explicitly specify -f(no)-second-underscore we
365 use it if we're trying to be compatible with f2c, and not
367 if (gfc_option
.flag_second_underscore
== -1)
368 gfc_option
.flag_second_underscore
= gfc_option
.flag_f2c
;
370 if (!gfc_option
.flag_automatic
&& gfc_option
.flag_max_stack_var_size
!= -2
371 && gfc_option
.flag_max_stack_var_size
!= 0)
372 gfc_warning_now ("Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
373 gfc_option
.flag_max_stack_var_size
);
374 else if (!gfc_option
.flag_automatic
&& gfc_option
.flag_recursive
)
375 gfc_warning_now ("Flag %<-fno-automatic%> overwrites %<-frecursive%>");
376 else if (!gfc_option
.flag_automatic
&& gfc_option
.gfc_flag_openmp
)
377 gfc_warning_now ("Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
379 else if (gfc_option
.flag_max_stack_var_size
!= -2
380 && gfc_option
.flag_recursive
)
381 gfc_warning_now ("Flag %<-frecursive%> overwrites %<-fmax-stack-var-size=%d%>",
382 gfc_option
.flag_max_stack_var_size
);
383 else if (gfc_option
.flag_max_stack_var_size
!= -2
384 && gfc_option
.gfc_flag_openmp
)
385 gfc_warning_now ("Flag %<-fmax-stack-var-size=%d%> overwrites %<-frecursive%> "
386 "implied by %<-fopenmp%>",
387 gfc_option
.flag_max_stack_var_size
);
389 /* Implement -frecursive as -fmax-stack-var-size=-1. */
390 if (gfc_option
.flag_recursive
)
391 gfc_option
.flag_max_stack_var_size
= -1;
393 /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
394 if (gfc_option
.flag_max_stack_var_size
== -2 && gfc_option
.gfc_flag_openmp
395 && gfc_option
.flag_automatic
)
397 gfc_option
.flag_recursive
= 1;
398 gfc_option
.flag_max_stack_var_size
= -1;
402 if (gfc_option
.flag_max_stack_var_size
== -2)
403 gfc_option
.flag_max_stack_var_size
= 32768;
405 /* Implement -fno-automatic as -fmax-stack-var-size=0. */
406 if (!gfc_option
.flag_automatic
)
407 gfc_option
.flag_max_stack_var_size
= 0;
409 /* Optimization implies front end optimization, unless the user
410 specified it directly. */
412 if (gfc_option
.flag_frontend_optimize
== -1)
413 gfc_option
.flag_frontend_optimize
= optimize
;
415 gfc_cpp_post_options ();
417 return gfc_cpp_preprocess_only ();
422 gfc_handle_module_path_options (const char *arg
)
425 if (gfc_option
.module_dir
!= NULL
)
426 gfc_fatal_error ("gfortran: Only one %<-J%> option allowed");
428 gfc_option
.module_dir
= XCNEWVEC (char, strlen (arg
) + 2);
429 strcpy (gfc_option
.module_dir
, arg
);
431 gfc_add_include_path (gfc_option
.module_dir
, true, false, true);
433 strcat (gfc_option
.module_dir
, "/");
437 /* Handle options -ffpe-trap= and -ffpe-summary=. */
440 gfc_handle_fpe_option (const char *arg
, bool trap
)
442 int result
, pos
= 0, n
;
443 /* precision is a backwards compatibility alias for inexact. */
444 static const char * const exception
[] = { "invalid", "denormal", "zero",
445 "overflow", "underflow",
446 "inexact", "precision", NULL
};
447 static const int opt_exception
[] = { GFC_FPE_INVALID
, GFC_FPE_DENORMAL
,
448 GFC_FPE_ZERO
, GFC_FPE_OVERFLOW
,
449 GFC_FPE_UNDERFLOW
, GFC_FPE_INEXACT
,
453 /* As the default for -ffpe-summary= is nonzero, set it to 0. */
455 gfc_option
.fpe_summary
= 0;
462 while (arg
[pos
] && arg
[pos
] != ',')
466 if (!trap
&& strncmp ("none", arg
, pos
) == 0)
468 gfc_option
.fpe_summary
= 0;
473 else if (!trap
&& strncmp ("all", arg
, pos
) == 0)
475 gfc_option
.fpe_summary
= GFC_FPE_INVALID
| GFC_FPE_DENORMAL
476 | GFC_FPE_ZERO
| GFC_FPE_OVERFLOW
477 | GFC_FPE_UNDERFLOW
| GFC_FPE_INEXACT
;
483 for (n
= 0; exception
[n
] != NULL
; n
++)
485 if (exception
[n
] && strncmp (exception
[n
], arg
, pos
) == 0)
488 gfc_option
.fpe
|= opt_exception
[n
];
490 gfc_option
.fpe_summary
|= opt_exception
[n
];
497 if (!result
&& !trap
)
498 gfc_fatal_error ("Argument to %<-ffpe-trap%> is not valid: %s", arg
);
500 gfc_fatal_error ("Argument to %<-ffpe-summary%> is not valid: %s", arg
);
507 gfc_handle_coarray_option (const char *arg
)
509 if (strcmp (arg
, "none") == 0)
510 gfc_option
.coarray
= GFC_FCOARRAY_NONE
;
511 else if (strcmp (arg
, "single") == 0)
512 gfc_option
.coarray
= GFC_FCOARRAY_SINGLE
;
513 else if (strcmp (arg
, "lib") == 0)
514 gfc_option
.coarray
= GFC_FCOARRAY_LIB
;
516 gfc_fatal_error ("Argument to %<-fcoarray%> is not valid: %s", arg
);
521 gfc_handle_runtime_check_option (const char *arg
)
523 int result
, pos
= 0, n
;
524 static const char * const optname
[] = { "all", "bounds", "array-temps",
525 "recursion", "do", "pointer",
527 static const int optmask
[] = { GFC_RTCHECK_ALL
, GFC_RTCHECK_BOUNDS
,
528 GFC_RTCHECK_ARRAY_TEMPS
,
529 GFC_RTCHECK_RECURSION
, GFC_RTCHECK_DO
,
530 GFC_RTCHECK_POINTER
, GFC_RTCHECK_MEM
,
538 while (arg
[pos
] && arg
[pos
] != ',')
542 for (n
= 0; optname
[n
] != NULL
; n
++)
544 if (optname
[n
] && strncmp (optname
[n
], arg
, pos
) == 0)
546 gfc_option
.rtcheck
|= optmask
[n
];
554 gfc_fatal_error ("Argument to %<-fcheck%> is not valid: %s", arg
);
559 /* Handle command-line options. Returns 0 if unrecognized, 1 if
560 recognized and handled. */
563 gfc_handle_option (size_t scode
, const char *arg
, int value
,
564 int kind ATTRIBUTE_UNUSED
, location_t loc ATTRIBUTE_UNUSED
,
565 const struct cl_option_handlers
*handlers ATTRIBUTE_UNUSED
)
568 enum opt_code code
= (enum opt_code
) scode
;
570 if (gfc_cpp_handle_option (scode
, arg
, value
) == 1)
576 if (cl_options
[code
].flags
& gfc_option_lang_mask ())
581 case OPT_fall_intrinsics
:
582 gfc_option
.flag_all_intrinsics
= 1;
586 gfc_option
.flag_automatic
= value
;
589 case OPT_fallow_leading_underscore
:
590 gfc_option
.flag_allow_leading_underscore
= value
;
594 gfc_option
.flag_backslash
= value
;
598 gfc_option
.flag_backtrace
= value
;
601 case OPT_fcheck_array_temporaries
:
602 gfc_option
.rtcheck
|= GFC_RTCHECK_ARRAY_TEMPS
;
605 case OPT_fcray_pointer
:
606 gfc_option
.flag_cray_pointer
= value
;
610 gfc_option
.flag_f2c
= value
;
614 gfc_option
.flag_dollar_ok
= value
;
617 case OPT_fexternal_blas
:
618 gfc_option
.flag_external_blas
= value
;
621 case OPT_fblas_matmul_limit_
:
622 gfc_option
.blas_matmul_limit
= value
;
625 case OPT_fd_lines_as_code
:
626 gfc_option
.flag_d_lines
= 1;
629 case OPT_fd_lines_as_comments
:
630 gfc_option
.flag_d_lines
= 0;
633 case OPT_fdump_fortran_original
:
634 case OPT_fdump_parse_tree
:
635 gfc_option
.dump_fortran_original
= value
;
638 case OPT_fdump_fortran_optimized
:
639 gfc_option
.dump_fortran_optimized
= value
;
642 case OPT_ffixed_form
:
643 gfc_option
.source_form
= FORM_FIXED
;
646 case OPT_ffixed_line_length_none
:
647 gfc_option
.fixed_line_length
= 0;
650 case OPT_ffixed_line_length_
:
651 if (value
!= 0 && value
< 7)
652 gfc_fatal_error ("Fixed line length must be at least seven");
653 gfc_option
.fixed_line_length
= value
;
657 gfc_option
.source_form
= FORM_FREE
;
661 gfc_option
.gfc_flag_openmp
= value
;
664 case OPT_fopenmp_simd
:
665 gfc_option
.gfc_flag_openmp_simd
= value
;
668 case OPT_ffree_line_length_none
:
669 gfc_option
.free_line_length
= 0;
672 case OPT_ffree_line_length_
:
673 if (value
!= 0 && value
< 4)
674 gfc_fatal_error ("Free line length must be at least three");
675 gfc_option
.free_line_length
= value
;
678 case OPT_funderscoring
:
679 gfc_option
.flag_underscoring
= value
;
682 case OPT_fsecond_underscore
:
683 gfc_option
.flag_second_underscore
= value
;
686 case OPT_static_libgfortran
:
687 #ifndef HAVE_LD_STATIC_DYNAMIC
688 gfc_fatal_error ("%<-static-libgfortran%> is not supported in this "
693 case OPT_fimplicit_none
:
694 gfc_option
.flag_implicit_none
= value
;
697 case OPT_fintrinsic_modules_path
:
698 case OPT_fintrinsic_modules_path_
:
700 /* This is needed because omp_lib.h is in a directory together
701 with intrinsic modules. Do no warn because during testing
702 without an installed compiler, we would get lots of bogus
703 warnings for a missing include directory. */
704 gfc_add_include_path (arg
, false, false, false);
706 gfc_add_intrinsic_modules_path (arg
);
709 case OPT_fmax_array_constructor_
:
710 gfc_option
.flag_max_array_constructor
= value
> 65535 ? value
: 65535;
713 case OPT_fmax_stack_var_size_
:
714 gfc_option
.flag_max_stack_var_size
= value
;
717 case OPT_fstack_arrays
:
718 gfc_option
.flag_stack_arrays
= value
;
721 case OPT_fmodule_private
:
722 gfc_option
.flag_module_private
= value
;
725 case OPT_frange_check
:
726 gfc_option
.flag_range_check
= value
;
729 case OPT_fpack_derived
:
730 gfc_option
.flag_pack_derived
= value
;
733 case OPT_frepack_arrays
:
734 gfc_option
.flag_repack_arrays
= value
;
737 case OPT_fpreprocessed
:
738 gfc_option
.flag_preprocessed
= value
;
741 case OPT_fmax_identifier_length_
:
742 if (value
> GFC_MAX_SYMBOL_LEN
)
743 gfc_fatal_error ("Maximum supported identifier length is %d",
745 gfc_option
.max_identifier_length
= value
;
748 case OPT_fdefault_integer_8
:
749 gfc_option
.flag_default_integer
= value
;
752 case OPT_fdefault_real_8
:
753 gfc_option
.flag_default_real
= value
;
756 case OPT_fdefault_double_8
:
757 gfc_option
.flag_default_double
= value
;
760 case OPT_finteger_4_integer_8
:
761 gfc_option
.flag_integer4_kind
= 8;
764 case OPT_freal_4_real_8
:
765 gfc_option
.flag_real4_kind
= 8;
768 case OPT_freal_4_real_10
:
769 gfc_option
.flag_real4_kind
= 10;
772 case OPT_freal_4_real_16
:
773 gfc_option
.flag_real4_kind
= 16;
776 case OPT_freal_8_real_4
:
777 gfc_option
.flag_real8_kind
= 4;
780 case OPT_freal_8_real_10
:
781 gfc_option
.flag_real8_kind
= 10;
784 case OPT_freal_8_real_16
:
785 gfc_option
.flag_real8_kind
= 16;
788 case OPT_finit_local_zero
:
789 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_ON
;
790 gfc_option
.flag_init_integer_value
= 0;
791 gfc_option
.flag_init_real
= GFC_INIT_REAL_ZERO
;
792 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_FALSE
;
793 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_ON
;
794 gfc_option
.flag_init_character_value
= (char)0;
797 case OPT_finit_logical_
:
798 if (!strcasecmp (arg
, "false"))
799 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_FALSE
;
800 else if (!strcasecmp (arg
, "true"))
801 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_TRUE
;
803 gfc_fatal_error ("Unrecognized option to %<-finit-logical%>: %s",
807 case OPT_finit_real_
:
808 if (!strcasecmp (arg
, "zero"))
809 gfc_option
.flag_init_real
= GFC_INIT_REAL_ZERO
;
810 else if (!strcasecmp (arg
, "nan"))
811 gfc_option
.flag_init_real
= GFC_INIT_REAL_NAN
;
812 else if (!strcasecmp (arg
, "snan"))
813 gfc_option
.flag_init_real
= GFC_INIT_REAL_SNAN
;
814 else if (!strcasecmp (arg
, "inf"))
815 gfc_option
.flag_init_real
= GFC_INIT_REAL_INF
;
816 else if (!strcasecmp (arg
, "-inf"))
817 gfc_option
.flag_init_real
= GFC_INIT_REAL_NEG_INF
;
819 gfc_fatal_error ("Unrecognized option to %<-finit-real%>: %s",
823 case OPT_finit_integer_
:
824 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_ON
;
825 gfc_option
.flag_init_integer_value
= atoi (arg
);
828 case OPT_finit_character_
:
829 if (value
>= 0 && value
<= 127)
831 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_ON
;
832 gfc_option
.flag_init_character_value
= (char)value
;
835 gfc_fatal_error ("The value of n in %<-finit-character=n%> must be "
836 "between 0 and 127");
840 gfc_add_include_path (arg
, true, false, true);
844 gfc_handle_module_path_options (arg
);
848 gfc_option
.flag_sign_zero
= value
;
852 gfc_handle_fpe_option (arg
, true);
855 case OPT_ffpe_summary_
:
856 gfc_handle_fpe_option (arg
, false);
860 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F95
| GFC_STD_F77
862 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
863 gfc_option
.max_continue_fixed
= 19;
864 gfc_option
.max_continue_free
= 39;
865 gfc_option
.max_identifier_length
= 31;
871 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
872 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008_OBS
;
873 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
874 gfc_option
.max_identifier_length
= 63;
880 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
881 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008
| GFC_STD_F2008_OBS
;
882 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2008_OBS
;
883 gfc_option
.max_identifier_length
= 63;
888 case OPT_std_f2008ts
:
889 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
890 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008
| GFC_STD_F2008_OBS
892 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2008_OBS
;
893 gfc_option
.max_identifier_length
= 63;
899 set_default_std_flags ();
903 set_default_std_flags ();
904 gfc_option
.warn_std
= 0;
907 case OPT_fshort_enums
:
908 /* Handled in language-independent code. */
911 case OPT_fconvert_little_endian
:
912 gfc_option
.convert
= GFC_CONVERT_LITTLE
;
915 case OPT_fconvert_big_endian
:
916 gfc_option
.convert
= GFC_CONVERT_BIG
;
919 case OPT_fconvert_native
:
920 gfc_option
.convert
= GFC_CONVERT_NATIVE
;
923 case OPT_fconvert_swap
:
924 gfc_option
.convert
= GFC_CONVERT_SWAP
;
927 case OPT_frecord_marker_4
:
928 gfc_option
.record_marker
= 4;
931 case OPT_frecord_marker_8
:
932 gfc_option
.record_marker
= 8;
935 case OPT_fmax_subrecord_length_
:
936 if (value
> MAX_SUBRECORD_LENGTH
)
937 gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
938 MAX_SUBRECORD_LENGTH
);
940 gfc_option
.max_subrecord_length
= value
;
944 gfc_option
.flag_recursive
= value
;
947 case OPT_falign_commons
:
948 gfc_option
.flag_align_commons
= value
;
951 case OPT_faggressive_function_elimination
:
952 gfc_option
.flag_aggressive_function_elimination
= value
;
955 case OPT_ffrontend_optimize
:
956 gfc_option
.flag_frontend_optimize
= value
;
959 case OPT_fprotect_parens
:
960 gfc_option
.flag_protect_parens
= value
;
963 case OPT_frealloc_lhs
:
964 gfc_option
.flag_realloc_lhs
= value
;
968 gfc_handle_runtime_check_option (arg
);
972 gfc_handle_coarray_option (arg
);
976 Fortran_handle_option_auto (&global_options
, &global_options_set
,
978 gfc_option_lang_mask (), kind
,
979 loc
, handlers
, global_dc
);
984 /* Return a string with the options passed to the compiler; used for
985 Fortran's compiler_options() intrinsic. */
988 gfc_get_option_string (void)
994 /* Allocate and return a one-character string with '\0'. */
995 if (!save_decoded_options_count
)
996 return XCNEWVEC (char, 1);
998 /* Determine required string length. */
1001 for (j
= 1; j
< save_decoded_options_count
; j
++)
1003 switch (save_decoded_options
[j
].opt_index
)
1012 case OPT_fintrinsic_modules_path
:
1013 case OPT_fintrinsic_modules_path_
:
1017 /* Ignore file names. */
1018 if (save_decoded_options
[j
].orig_option_with_args_text
[0] == '-')
1020 + strlen (save_decoded_options
[j
].orig_option_with_args_text
);
1024 result
= XCNEWVEC (char, len
);
1027 for (j
= 1; j
< save_decoded_options_count
; j
++)
1029 switch (save_decoded_options
[j
].opt_index
)
1038 case OPT_fintrinsic_modules_path
:
1039 case OPT_fintrinsic_modules_path_
:
1044 /* Use "-cpp" rather than "-cpp=<temporary file>". */
1049 /* Ignore file names. */
1050 if (save_decoded_options
[j
].orig_option_with_args_text
[0] != '-')
1053 len
= strlen (save_decoded_options
[j
].orig_option_with_args_text
);
1056 memcpy (&result
[pos
], save_decoded_options
[j
].orig_option_with_args_text
, len
);
1058 result
[pos
++] = ' ';
1061 result
[--pos
] = '\0';