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
.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
.warn_c_binding_type
= 0;
101 gfc_option
.gfc_warn_conversion
= 0;
102 gfc_option
.warn_conversion_extra
= 0;
103 gfc_option
.warn_function_elimination
= 0;
104 gfc_option
.warn_implicit_interface
= 0;
105 gfc_option
.warn_line_truncation
= 0;
106 gfc_option
.warn_surprising
= 0;
107 gfc_option
.warn_tabs
= 1;
108 gfc_option
.warn_underflow
= 1;
109 gfc_option
.warn_intrinsic_shadow
= 0;
110 gfc_option
.warn_use_without_only
= 0;
111 gfc_option
.warn_intrinsics_std
= 0;
112 gfc_option
.warn_align_commons
= 1;
113 gfc_option
.warn_real_q_constant
= 0;
114 gfc_option
.warn_unused_dummy_argument
= 0;
115 gfc_option
.warn_zerotrip
= 0;
116 gfc_option
.warn_realloc_lhs
= 0;
117 gfc_option
.warn_realloc_lhs_all
= 0;
118 gfc_option
.warn_compare_reals
= 0;
119 gfc_option
.warn_target_lifetime
= 0;
120 gfc_option
.max_errors
= 25;
122 gfc_option
.flag_all_intrinsics
= 0;
123 gfc_option
.flag_default_double
= 0;
124 gfc_option
.flag_default_integer
= 0;
125 gfc_option
.flag_default_real
= 0;
126 gfc_option
.flag_integer4_kind
= 0;
127 gfc_option
.flag_real4_kind
= 0;
128 gfc_option
.flag_real8_kind
= 0;
129 gfc_option
.flag_dollar_ok
= 0;
130 gfc_option
.flag_underscoring
= 1;
131 gfc_option
.flag_f2c
= 0;
132 gfc_option
.flag_second_underscore
= -1;
133 gfc_option
.flag_implicit_none
= 0;
135 /* Default value of flag_max_stack_var_size is set in gfc_post_options. */
136 gfc_option
.flag_max_stack_var_size
= -2;
137 gfc_option
.flag_stack_arrays
= -1;
139 gfc_option
.flag_range_check
= 1;
140 gfc_option
.flag_pack_derived
= 0;
141 gfc_option
.flag_repack_arrays
= 0;
142 gfc_option
.flag_preprocessed
= 0;
143 gfc_option
.flag_automatic
= 1;
144 gfc_option
.flag_backslash
= 0;
145 gfc_option
.flag_module_private
= 0;
146 gfc_option
.flag_backtrace
= 1;
147 gfc_option
.flag_allow_leading_underscore
= 0;
148 gfc_option
.flag_external_blas
= 0;
149 gfc_option
.blas_matmul_limit
= 30;
150 gfc_option
.flag_cray_pointer
= 0;
151 gfc_option
.flag_d_lines
= -1;
152 gfc_option
.gfc_flag_openmp
= 0;
153 gfc_option
.flag_sign_zero
= 1;
154 gfc_option
.flag_recursive
= 0;
155 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_OFF
;
156 gfc_option
.flag_init_integer_value
= 0;
157 gfc_option
.flag_init_real
= GFC_INIT_REAL_OFF
;
158 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_OFF
;
159 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_OFF
;
160 gfc_option
.flag_init_character_value
= (char)0;
161 gfc_option
.flag_align_commons
= 1;
162 gfc_option
.flag_protect_parens
= -1;
163 gfc_option
.flag_realloc_lhs
= -1;
164 gfc_option
.flag_aggressive_function_elimination
= 0;
165 gfc_option
.flag_frontend_optimize
= -1;
168 /* All except GFC_FPE_INEXACT. */
169 gfc_option
.fpe_summary
= GFC_FPE_INVALID
| GFC_FPE_DENORMAL
170 | GFC_FPE_ZERO
| GFC_FPE_OVERFLOW
172 gfc_option
.rtcheck
= 0;
173 gfc_option
.coarray
= GFC_FCOARRAY_NONE
;
175 /* ??? Wmissing-include-dirs is disabled by default in C/C++ but
176 enabled by default in Fortran. Ideally, we should express this
177 in .opt, but that is not supported yet. */
178 if (!global_options_set
.x_cpp_warn_missing_include_dirs
)
179 global_options
.x_cpp_warn_missing_include_dirs
= 1;;
181 set_default_std_flags ();
183 /* Initialize cpp-related options. */
184 gfc_cpp_init_options (decoded_options_count
, decoded_options
);
185 gfc_diagnostics_init ();
189 /* Determine the source form from the filename extension. We assume
190 case insensitivity. */
192 static gfc_source_form
193 form_from_filename (const char *filename
)
197 const char *extension
;
198 gfc_source_form form
;
225 }; /* sentinel value */
227 gfc_source_form f_form
;
231 /* Find end of file name. Note, filename is either a NULL pointer or
232 a NUL terminated string. */
234 while (filename
[i
] != '\0')
237 /* Find last period. */
238 while (i
>= 0 && (filename
[i
] != '.'))
241 /* Did we see a file extension? */
243 return FORM_UNKNOWN
; /* Nope */
245 /* Get file extension and compare it to others. */
246 fileext
= &(filename
[i
]);
249 f_form
= FORM_UNKNOWN
;
253 if (strcasecmp (fileext
, exttype
[i
].extension
) == 0)
255 f_form
= exttype
[i
].form
;
259 while (exttype
[i
].form
!= FORM_UNKNOWN
);
265 /* Finalize commandline options. */
268 gfc_post_options (const char **pfilename
)
270 const char *filename
= *pfilename
, *canon_source_file
= NULL
;
274 /* Excess precision other than "fast" requires front-end
276 if (flag_excess_precision_cmdline
== EXCESS_PRECISION_STANDARD
277 && TARGET_FLT_EVAL_METHOD_NON_DEFAULT
)
278 sorry ("-fexcess-precision=standard for Fortran");
279 flag_excess_precision_cmdline
= EXCESS_PRECISION_FAST
;
281 /* Fortran allows associative math - but we cannot reassociate if
282 we want traps or signed zeros. Cf. also flag_protect_parens. */
283 if (flag_associative_math
== -1)
284 flag_associative_math
= (!flag_trapping_math
&& !flag_signed_zeros
);
286 if (gfc_option
.flag_protect_parens
== -1)
287 gfc_option
.flag_protect_parens
= !optimize_fast
;
289 if (gfc_option
.flag_stack_arrays
== -1)
290 gfc_option
.flag_stack_arrays
= optimize_fast
;
292 /* By default, disable (re)allocation during assignment for -std=f95,
293 and enable it for F2003/F2008/GNU/Legacy. */
294 if (gfc_option
.flag_realloc_lhs
== -1)
296 if (gfc_option
.allow_std
& GFC_STD_F2003
)
297 gfc_option
.flag_realloc_lhs
= 1;
299 gfc_option
.flag_realloc_lhs
= 0;
302 /* -fbounds-check is equivalent to -fcheck=bounds */
303 if (flag_bounds_check
)
304 gfc_option
.rtcheck
|= GFC_RTCHECK_BOUNDS
;
306 if (flag_compare_debug
)
307 gfc_option
.dump_fortran_original
= 0;
309 /* Make -fmax-errors visible to gfortran's diagnostic machinery. */
310 if (global_options_set
.x_flag_max_errors
)
311 gfc_option
.max_errors
= flag_max_errors
;
313 /* Verify the input file name. */
314 if (!filename
|| strcmp (filename
, "-") == 0)
319 if (gfc_option
.flag_preprocessed
)
321 /* For preprocessed files, if the first tokens are of the form # NUM.
322 handle the directives so we know the original file name. */
323 gfc_source_file
= gfc_read_orig_filename (filename
, &canon_source_file
);
324 if (gfc_source_file
== NULL
)
325 gfc_source_file
= filename
;
327 *pfilename
= gfc_source_file
;
330 gfc_source_file
= filename
;
332 if (canon_source_file
== NULL
)
333 canon_source_file
= gfc_source_file
;
335 /* Adds the path where the source file is to the list of include files. */
337 i
= strlen (canon_source_file
);
338 while (i
> 0 && !IS_DIR_SEPARATOR (canon_source_file
[i
]))
343 source_path
= (char *) alloca (i
+ 1);
344 memcpy (source_path
, canon_source_file
, i
);
346 gfc_add_include_path (source_path
, true, true, true);
349 gfc_add_include_path (".", true, true, true);
351 if (canon_source_file
!= gfc_source_file
)
352 free (CONST_CAST (char *, canon_source_file
));
354 /* Decide which form the file will be read in as. */
356 if (gfc_option
.source_form
!= FORM_UNKNOWN
)
357 gfc_current_form
= gfc_option
.source_form
;
360 gfc_current_form
= form_from_filename (filename
);
362 if (gfc_current_form
== FORM_UNKNOWN
)
364 gfc_current_form
= FORM_FREE
;
365 gfc_warning_cmdline ("Reading file %qs as free form",
366 (filename
[0] == '\0') ? "<stdin>" : filename
);
370 /* If the user specified -fd-lines-as-{code|comments} verify that we're
372 if (gfc_current_form
== FORM_FREE
)
374 if (gfc_option
.flag_d_lines
== 0)
375 gfc_warning_cmdline ("%<-fd-lines-as-comments%> has no effect "
377 else if (gfc_option
.flag_d_lines
== 1)
378 gfc_warning_cmdline ("%<-fd-lines-as-code%> has no effect in free form");
381 /* If -pedantic, warn about the use of GNU extensions. */
382 if (pedantic
&& (gfc_option
.allow_std
& GFC_STD_GNU
) != 0)
383 gfc_option
.warn_std
|= GFC_STD_GNU
;
384 /* -std=legacy -pedantic is effectively -std=gnu. */
385 if (pedantic
&& (gfc_option
.allow_std
& GFC_STD_LEGACY
) != 0)
386 gfc_option
.warn_std
|= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
| GFC_STD_LEGACY
;
388 /* If the user didn't explicitly specify -f(no)-second-underscore we
389 use it if we're trying to be compatible with f2c, and not
391 if (gfc_option
.flag_second_underscore
== -1)
392 gfc_option
.flag_second_underscore
= gfc_option
.flag_f2c
;
394 if (!gfc_option
.flag_automatic
&& gfc_option
.flag_max_stack_var_size
!= -2
395 && gfc_option
.flag_max_stack_var_size
!= 0)
396 gfc_warning_cmdline ("Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
397 gfc_option
.flag_max_stack_var_size
);
398 else if (!gfc_option
.flag_automatic
&& gfc_option
.flag_recursive
)
399 gfc_warning_cmdline ("Flag %<-fno-automatic%> overwrites %<-frecursive%>");
400 else if (!gfc_option
.flag_automatic
&& gfc_option
.gfc_flag_openmp
)
401 gfc_warning_cmdline ("Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
403 else if (gfc_option
.flag_max_stack_var_size
!= -2
404 && gfc_option
.flag_recursive
)
405 gfc_warning_cmdline ("Flag %<-frecursive%> overwrites %<-fmax-stack-var-size=%d%>",
406 gfc_option
.flag_max_stack_var_size
);
407 else if (gfc_option
.flag_max_stack_var_size
!= -2
408 && gfc_option
.gfc_flag_openmp
)
409 gfc_warning_cmdline ("Flag %<-fmax-stack-var-size=%d%> overwrites %<-frecursive%> "
410 "implied by %<-fopenmp%>",
411 gfc_option
.flag_max_stack_var_size
);
413 /* Implement -frecursive as -fmax-stack-var-size=-1. */
414 if (gfc_option
.flag_recursive
)
415 gfc_option
.flag_max_stack_var_size
= -1;
417 /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
418 if (gfc_option
.flag_max_stack_var_size
== -2 && gfc_option
.gfc_flag_openmp
419 && gfc_option
.flag_automatic
)
421 gfc_option
.flag_recursive
= 1;
422 gfc_option
.flag_max_stack_var_size
= -1;
426 if (gfc_option
.flag_max_stack_var_size
== -2)
427 gfc_option
.flag_max_stack_var_size
= 32768;
429 /* Implement -fno-automatic as -fmax-stack-var-size=0. */
430 if (!gfc_option
.flag_automatic
)
431 gfc_option
.flag_max_stack_var_size
= 0;
435 gfc_option
.warn_ampersand
= 1;
436 gfc_option
.warn_tabs
= 0;
439 /* Optimization implies front end optimization, unless the user
440 specified it directly. */
442 if (gfc_option
.flag_frontend_optimize
== -1)
443 gfc_option
.flag_frontend_optimize
= optimize
;
445 if (gfc_option
.warn_realloc_lhs_all
)
446 gfc_option
.warn_realloc_lhs
= 1;
448 gfc_cpp_post_options ();
450 return gfc_cpp_preprocess_only ();
454 /* Set the options for -Wall. */
457 set_Wall (int setting
)
459 gfc_option
.warn_aliasing
= setting
;
460 gfc_option
.warn_ampersand
= setting
;
461 gfc_option
.warn_c_binding_type
= setting
;
462 gfc_option
.gfc_warn_conversion
= setting
;
463 gfc_option
.warn_line_truncation
= setting
;
464 gfc_option
.warn_surprising
= setting
;
465 gfc_option
.warn_tabs
= !setting
;
466 gfc_option
.warn_underflow
= setting
;
467 gfc_option
.warn_intrinsic_shadow
= setting
;
468 gfc_option
.warn_intrinsics_std
= setting
;
469 gfc_option
.warn_character_truncation
= setting
;
470 gfc_option
.warn_real_q_constant
= setting
;
471 gfc_option
.warn_unused_dummy_argument
= setting
;
472 gfc_option
.warn_target_lifetime
= setting
;
473 gfc_option
.warn_zerotrip
= setting
;
475 warn_return_type
= setting
;
476 warn_uninitialized
= setting
;
477 warn_maybe_uninitialized
= setting
;
480 /* Set the options for -Wextra. */
483 set_Wextra (int setting
)
485 gfc_option
.warn_compare_reals
= setting
;
489 gfc_handle_module_path_options (const char *arg
)
492 if (gfc_option
.module_dir
!= NULL
)
493 gfc_fatal_error ("gfortran: Only one -J option allowed");
495 gfc_option
.module_dir
= XCNEWVEC (char, strlen (arg
) + 2);
496 strcpy (gfc_option
.module_dir
, arg
);
498 gfc_add_include_path (gfc_option
.module_dir
, true, false, true);
500 strcat (gfc_option
.module_dir
, "/");
504 /* Handle options -ffpe-trap= and -ffpe-summary=. */
507 gfc_handle_fpe_option (const char *arg
, bool trap
)
509 int result
, pos
= 0, n
;
510 /* precision is a backwards compatibility alias for inexact. */
511 static const char * const exception
[] = { "invalid", "denormal", "zero",
512 "overflow", "underflow",
513 "inexact", "precision", NULL
};
514 static const int opt_exception
[] = { GFC_FPE_INVALID
, GFC_FPE_DENORMAL
,
515 GFC_FPE_ZERO
, GFC_FPE_OVERFLOW
,
516 GFC_FPE_UNDERFLOW
, GFC_FPE_INEXACT
,
520 /* As the default for -ffpe-summary= is nonzero, set it to 0. */
522 gfc_option
.fpe_summary
= 0;
529 while (arg
[pos
] && arg
[pos
] != ',')
533 if (!trap
&& strncmp ("none", arg
, pos
) == 0)
535 gfc_option
.fpe_summary
= 0;
540 else if (!trap
&& strncmp ("all", arg
, pos
) == 0)
542 gfc_option
.fpe_summary
= GFC_FPE_INVALID
| GFC_FPE_DENORMAL
543 | GFC_FPE_ZERO
| GFC_FPE_OVERFLOW
544 | GFC_FPE_UNDERFLOW
| GFC_FPE_INEXACT
;
550 for (n
= 0; exception
[n
] != NULL
; n
++)
552 if (exception
[n
] && strncmp (exception
[n
], arg
, pos
) == 0)
555 gfc_option
.fpe
|= opt_exception
[n
];
557 gfc_option
.fpe_summary
|= opt_exception
[n
];
564 if (!result
&& !trap
)
565 gfc_fatal_error ("Argument to -ffpe-trap is not valid: %s", arg
);
567 gfc_fatal_error ("Argument to -ffpe-summary is not valid: %s", arg
);
574 gfc_handle_coarray_option (const char *arg
)
576 if (strcmp (arg
, "none") == 0)
577 gfc_option
.coarray
= GFC_FCOARRAY_NONE
;
578 else if (strcmp (arg
, "single") == 0)
579 gfc_option
.coarray
= GFC_FCOARRAY_SINGLE
;
580 else if (strcmp (arg
, "lib") == 0)
581 gfc_option
.coarray
= GFC_FCOARRAY_LIB
;
583 gfc_fatal_error ("Argument to -fcoarray is not valid: %s", arg
);
588 gfc_handle_runtime_check_option (const char *arg
)
590 int result
, pos
= 0, n
;
591 static const char * const optname
[] = { "all", "bounds", "array-temps",
592 "recursion", "do", "pointer",
594 static const int optmask
[] = { GFC_RTCHECK_ALL
, GFC_RTCHECK_BOUNDS
,
595 GFC_RTCHECK_ARRAY_TEMPS
,
596 GFC_RTCHECK_RECURSION
, GFC_RTCHECK_DO
,
597 GFC_RTCHECK_POINTER
, GFC_RTCHECK_MEM
,
605 while (arg
[pos
] && arg
[pos
] != ',')
609 for (n
= 0; optname
[n
] != NULL
; n
++)
611 if (optname
[n
] && strncmp (optname
[n
], arg
, pos
) == 0)
613 gfc_option
.rtcheck
|= optmask
[n
];
621 gfc_fatal_error ("Argument to -fcheck is not valid: %s", arg
);
626 /* Handle command-line options. Returns 0 if unrecognized, 1 if
627 recognized and handled. */
630 gfc_handle_option (size_t scode
, const char *arg
, int value
,
631 int kind ATTRIBUTE_UNUSED
, location_t loc ATTRIBUTE_UNUSED
,
632 const struct cl_option_handlers
*handlers ATTRIBUTE_UNUSED
)
635 enum opt_code code
= (enum opt_code
) scode
;
637 if (gfc_cpp_handle_option (scode
, arg
, value
) == 1)
643 if (cl_options
[code
].flags
& gfc_option_lang_mask ())
649 handle_generated_option (&global_options
, &global_options_set
,
650 OPT_Wunused
, NULL
, value
,
651 gfc_option_lang_mask (), kind
, loc
,
652 handlers
, global_dc
);
657 gfc_option
.warn_aliasing
= value
;
661 gfc_option
.warn_ampersand
= value
;
664 case OPT_Warray_temporaries
:
665 gfc_option
.warn_array_temp
= value
;
668 case OPT_Wc_binding_type
:
669 gfc_option
.warn_c_binding_type
= value
;
672 case OPT_Wcharacter_truncation
:
673 gfc_option
.warn_character_truncation
= value
;
676 case OPT_Wcompare_reals
:
677 gfc_option
.warn_compare_reals
= value
;
680 case OPT_Wconversion
:
681 gfc_option
.gfc_warn_conversion
= value
;
684 case OPT_Wconversion_extra
:
685 gfc_option
.warn_conversion_extra
= value
;
692 case OPT_Wfunction_elimination
:
693 gfc_option
.warn_function_elimination
= value
;
696 case OPT_Wimplicit_interface
:
697 gfc_option
.warn_implicit_interface
= value
;
700 case OPT_Wimplicit_procedure
:
701 gfc_option
.warn_implicit_procedure
= value
;
704 case OPT_Wline_truncation
:
705 gfc_option
.warn_line_truncation
= value
;
708 case OPT_Wrealloc_lhs
:
709 gfc_option
.warn_realloc_lhs
= value
;
712 case OPT_Wrealloc_lhs_all
:
713 gfc_option
.warn_realloc_lhs_all
= value
;
716 case OPT_Wreturn_type
:
717 warn_return_type
= value
;
720 case OPT_Wsurprising
:
721 gfc_option
.warn_surprising
= value
;
725 gfc_option
.warn_tabs
= value
;
728 case OPT_Wtarget_lifetime
:
729 gfc_option
.warn_target_lifetime
= value
;
733 gfc_option
.warn_underflow
= value
;
736 case OPT_Wintrinsic_shadow
:
737 gfc_option
.warn_intrinsic_shadow
= value
;
740 case OPT_Wuse_without_only
:
741 gfc_option
.warn_use_without_only
= value
;
744 case OPT_Walign_commons
:
745 gfc_option
.warn_align_commons
= value
;
748 case OPT_Wreal_q_constant
:
749 gfc_option
.warn_real_q_constant
= value
;
752 case OPT_Wunused_dummy_argument
:
753 gfc_option
.warn_unused_dummy_argument
= value
;
757 gfc_option
.warn_zerotrip
= value
;
760 case OPT_fall_intrinsics
:
761 gfc_option
.flag_all_intrinsics
= 1;
765 gfc_option
.flag_automatic
= value
;
768 case OPT_fallow_leading_underscore
:
769 gfc_option
.flag_allow_leading_underscore
= value
;
773 gfc_option
.flag_backslash
= value
;
777 gfc_option
.flag_backtrace
= value
;
780 case OPT_fcheck_array_temporaries
:
781 gfc_option
.rtcheck
|= GFC_RTCHECK_ARRAY_TEMPS
;
784 case OPT_fcray_pointer
:
785 gfc_option
.flag_cray_pointer
= value
;
789 gfc_option
.flag_f2c
= value
;
793 gfc_option
.flag_dollar_ok
= value
;
796 case OPT_fexternal_blas
:
797 gfc_option
.flag_external_blas
= value
;
800 case OPT_fblas_matmul_limit_
:
801 gfc_option
.blas_matmul_limit
= value
;
804 case OPT_fd_lines_as_code
:
805 gfc_option
.flag_d_lines
= 1;
808 case OPT_fd_lines_as_comments
:
809 gfc_option
.flag_d_lines
= 0;
812 case OPT_fdump_fortran_original
:
813 case OPT_fdump_parse_tree
:
814 gfc_option
.dump_fortran_original
= value
;
817 case OPT_fdump_fortran_optimized
:
818 gfc_option
.dump_fortran_optimized
= value
;
821 case OPT_ffixed_form
:
822 gfc_option
.source_form
= FORM_FIXED
;
825 case OPT_ffixed_line_length_none
:
826 gfc_option
.fixed_line_length
= 0;
829 case OPT_ffixed_line_length_
:
830 if (value
!= 0 && value
< 7)
831 gfc_fatal_error ("Fixed line length must be at least seven.");
832 gfc_option
.fixed_line_length
= value
;
836 gfc_option
.source_form
= FORM_FREE
;
840 gfc_option
.gfc_flag_openmp
= value
;
843 case OPT_fopenmp_simd
:
844 gfc_option
.gfc_flag_openmp_simd
= value
;
847 case OPT_ffree_line_length_none
:
848 gfc_option
.free_line_length
= 0;
851 case OPT_ffree_line_length_
:
852 if (value
!= 0 && value
< 4)
853 gfc_fatal_error ("Free line length must be at least three.");
854 gfc_option
.free_line_length
= value
;
857 case OPT_funderscoring
:
858 gfc_option
.flag_underscoring
= value
;
861 case OPT_fsecond_underscore
:
862 gfc_option
.flag_second_underscore
= value
;
865 case OPT_static_libgfortran
:
866 #ifndef HAVE_LD_STATIC_DYNAMIC
867 gfc_fatal_error ("-static-libgfortran is not supported in this "
872 case OPT_fimplicit_none
:
873 gfc_option
.flag_implicit_none
= value
;
876 case OPT_fintrinsic_modules_path
:
877 case OPT_fintrinsic_modules_path_
:
879 /* This is needed because omp_lib.h is in a directory together
880 with intrinsic modules. Do no warn because during testing
881 without an installed compiler, we would get lots of bogus
882 warnings for a missing include directory. */
883 gfc_add_include_path (arg
, false, false, false);
885 gfc_add_intrinsic_modules_path (arg
);
888 case OPT_fmax_array_constructor_
:
889 gfc_option
.flag_max_array_constructor
= value
> 65535 ? value
: 65535;
892 case OPT_fmax_stack_var_size_
:
893 gfc_option
.flag_max_stack_var_size
= value
;
896 case OPT_fstack_arrays
:
897 gfc_option
.flag_stack_arrays
= value
;
900 case OPT_fmodule_private
:
901 gfc_option
.flag_module_private
= value
;
904 case OPT_frange_check
:
905 gfc_option
.flag_range_check
= value
;
908 case OPT_fpack_derived
:
909 gfc_option
.flag_pack_derived
= value
;
912 case OPT_frepack_arrays
:
913 gfc_option
.flag_repack_arrays
= value
;
916 case OPT_fpreprocessed
:
917 gfc_option
.flag_preprocessed
= value
;
920 case OPT_fmax_identifier_length_
:
921 if (value
> GFC_MAX_SYMBOL_LEN
)
922 gfc_fatal_error ("Maximum supported identifier length is %d",
924 gfc_option
.max_identifier_length
= value
;
927 case OPT_fdefault_integer_8
:
928 gfc_option
.flag_default_integer
= value
;
931 case OPT_fdefault_real_8
:
932 gfc_option
.flag_default_real
= value
;
935 case OPT_fdefault_double_8
:
936 gfc_option
.flag_default_double
= value
;
939 case OPT_finteger_4_integer_8
:
940 gfc_option
.flag_integer4_kind
= 8;
943 case OPT_freal_4_real_8
:
944 gfc_option
.flag_real4_kind
= 8;
947 case OPT_freal_4_real_10
:
948 gfc_option
.flag_real4_kind
= 10;
951 case OPT_freal_4_real_16
:
952 gfc_option
.flag_real4_kind
= 16;
955 case OPT_freal_8_real_4
:
956 gfc_option
.flag_real8_kind
= 4;
959 case OPT_freal_8_real_10
:
960 gfc_option
.flag_real8_kind
= 10;
963 case OPT_freal_8_real_16
:
964 gfc_option
.flag_real8_kind
= 16;
967 case OPT_finit_local_zero
:
968 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_ON
;
969 gfc_option
.flag_init_integer_value
= 0;
970 gfc_option
.flag_init_real
= GFC_INIT_REAL_ZERO
;
971 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_FALSE
;
972 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_ON
;
973 gfc_option
.flag_init_character_value
= (char)0;
976 case OPT_finit_logical_
:
977 if (!strcasecmp (arg
, "false"))
978 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_FALSE
;
979 else if (!strcasecmp (arg
, "true"))
980 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_TRUE
;
982 gfc_fatal_error ("Unrecognized option to -finit-logical: %s",
986 case OPT_finit_real_
:
987 if (!strcasecmp (arg
, "zero"))
988 gfc_option
.flag_init_real
= GFC_INIT_REAL_ZERO
;
989 else if (!strcasecmp (arg
, "nan"))
990 gfc_option
.flag_init_real
= GFC_INIT_REAL_NAN
;
991 else if (!strcasecmp (arg
, "snan"))
992 gfc_option
.flag_init_real
= GFC_INIT_REAL_SNAN
;
993 else if (!strcasecmp (arg
, "inf"))
994 gfc_option
.flag_init_real
= GFC_INIT_REAL_INF
;
995 else if (!strcasecmp (arg
, "-inf"))
996 gfc_option
.flag_init_real
= GFC_INIT_REAL_NEG_INF
;
998 gfc_fatal_error ("Unrecognized option to -finit-real: %s",
1002 case OPT_finit_integer_
:
1003 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_ON
;
1004 gfc_option
.flag_init_integer_value
= atoi (arg
);
1007 case OPT_finit_character_
:
1008 if (value
>= 0 && value
<= 127)
1010 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_ON
;
1011 gfc_option
.flag_init_character_value
= (char)value
;
1014 gfc_fatal_error ("The value of n in -finit-character=n must be "
1015 "between 0 and 127");
1019 gfc_add_include_path (arg
, true, false, true);
1023 gfc_handle_module_path_options (arg
);
1026 case OPT_fsign_zero
:
1027 gfc_option
.flag_sign_zero
= value
;
1030 case OPT_ffpe_trap_
:
1031 gfc_handle_fpe_option (arg
, true);
1034 case OPT_ffpe_summary_
:
1035 gfc_handle_fpe_option (arg
, false);
1039 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F95
| GFC_STD_F77
1040 | GFC_STD_F2008_OBS
;
1041 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
1042 gfc_option
.max_continue_fixed
= 19;
1043 gfc_option
.max_continue_free
= 39;
1044 gfc_option
.max_identifier_length
= 31;
1045 gfc_option
.warn_ampersand
= 1;
1046 gfc_option
.warn_tabs
= 0;
1050 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
1051 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008_OBS
;
1052 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
1053 gfc_option
.max_identifier_length
= 63;
1054 gfc_option
.warn_ampersand
= 1;
1055 gfc_option
.warn_tabs
= 0;
1059 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
1060 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008
| GFC_STD_F2008_OBS
;
1061 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2008_OBS
;
1062 gfc_option
.max_identifier_length
= 63;
1063 gfc_option
.warn_ampersand
= 1;
1064 gfc_option
.warn_tabs
= 0;
1067 case OPT_std_f2008ts
:
1068 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
1069 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008
| GFC_STD_F2008_OBS
1071 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2008_OBS
;
1072 gfc_option
.max_identifier_length
= 63;
1073 gfc_option
.warn_ampersand
= 1;
1074 gfc_option
.warn_tabs
= 0;
1078 set_default_std_flags ();
1081 case OPT_std_legacy
:
1082 set_default_std_flags ();
1083 gfc_option
.warn_std
= 0;
1086 case OPT_Wintrinsics_std
:
1087 gfc_option
.warn_intrinsics_std
= value
;
1090 case OPT_fshort_enums
:
1091 /* Handled in language-independent code. */
1094 case OPT_fconvert_little_endian
:
1095 gfc_option
.convert
= GFC_CONVERT_LITTLE
;
1098 case OPT_fconvert_big_endian
:
1099 gfc_option
.convert
= GFC_CONVERT_BIG
;
1102 case OPT_fconvert_native
:
1103 gfc_option
.convert
= GFC_CONVERT_NATIVE
;
1106 case OPT_fconvert_swap
:
1107 gfc_option
.convert
= GFC_CONVERT_SWAP
;
1110 case OPT_frecord_marker_4
:
1111 gfc_option
.record_marker
= 4;
1114 case OPT_frecord_marker_8
:
1115 gfc_option
.record_marker
= 8;
1118 case OPT_fmax_subrecord_length_
:
1119 if (value
> MAX_SUBRECORD_LENGTH
)
1120 gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
1121 MAX_SUBRECORD_LENGTH
);
1123 gfc_option
.max_subrecord_length
= value
;
1126 case OPT_frecursive
:
1127 gfc_option
.flag_recursive
= value
;
1130 case OPT_falign_commons
:
1131 gfc_option
.flag_align_commons
= value
;
1134 case OPT_faggressive_function_elimination
:
1135 gfc_option
.flag_aggressive_function_elimination
= value
;
1138 case OPT_ffrontend_optimize
:
1139 gfc_option
.flag_frontend_optimize
= value
;
1142 case OPT_fprotect_parens
:
1143 gfc_option
.flag_protect_parens
= value
;
1146 case OPT_frealloc_lhs
:
1147 gfc_option
.flag_realloc_lhs
= value
;
1151 gfc_handle_runtime_check_option (arg
);
1155 gfc_handle_coarray_option (arg
);
1159 Fortran_handle_option_auto (&global_options
, &global_options_set
,
1161 gfc_option_lang_mask (), kind
,
1162 loc
, handlers
, global_dc
);
1167 /* Return a string with the options passed to the compiler; used for
1168 Fortran's compiler_options() intrinsic. */
1171 gfc_get_option_string (void)
1177 /* Allocate and return a one-character string with '\0'. */
1178 if (!save_decoded_options_count
)
1179 return XCNEWVEC (char, 1);
1181 /* Determine required string length. */
1184 for (j
= 1; j
< save_decoded_options_count
; j
++)
1186 switch (save_decoded_options
[j
].opt_index
)
1195 case OPT_fintrinsic_modules_path
:
1196 case OPT_fintrinsic_modules_path_
:
1200 /* Ignore file names. */
1201 if (save_decoded_options
[j
].orig_option_with_args_text
[0] == '-')
1203 + strlen (save_decoded_options
[j
].orig_option_with_args_text
);
1207 result
= XCNEWVEC (char, len
);
1210 for (j
= 1; j
< save_decoded_options_count
; j
++)
1212 switch (save_decoded_options
[j
].opt_index
)
1221 case OPT_fintrinsic_modules_path
:
1222 case OPT_fintrinsic_modules_path_
:
1227 /* Use "-cpp" rather than "-cpp=<temporary file>". */
1232 /* Ignore file names. */
1233 if (save_decoded_options
[j
].orig_option_with_args_text
[0] != '-')
1236 len
= strlen (save_decoded_options
[j
].orig_option_with_args_text
);
1239 memcpy (&result
[pos
], save_decoded_options
[j
].orig_option_with_args_text
, len
);
1241 result
[pos
++] = ' ';
1244 result
[--pos
] = '\0';