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_intrinsics_std
= 0;
111 gfc_option
.warn_align_commons
= 1;
112 gfc_option
.warn_real_q_constant
= 0;
113 gfc_option
.warn_unused_dummy_argument
= 0;
114 gfc_option
.warn_zerotrip
= 0;
115 gfc_option
.warn_realloc_lhs
= 0;
116 gfc_option
.warn_realloc_lhs_all
= 0;
117 gfc_option
.warn_compare_reals
= 0;
118 gfc_option
.warn_target_lifetime
= 0;
119 gfc_option
.max_errors
= 25;
121 gfc_option
.flag_all_intrinsics
= 0;
122 gfc_option
.flag_default_double
= 0;
123 gfc_option
.flag_default_integer
= 0;
124 gfc_option
.flag_default_real
= 0;
125 gfc_option
.flag_integer4_kind
= 0;
126 gfc_option
.flag_real4_kind
= 0;
127 gfc_option
.flag_real8_kind
= 0;
128 gfc_option
.flag_dollar_ok
= 0;
129 gfc_option
.flag_underscoring
= 1;
130 gfc_option
.flag_f2c
= 0;
131 gfc_option
.flag_second_underscore
= -1;
132 gfc_option
.flag_implicit_none
= 0;
134 /* Default value of flag_max_stack_var_size is set in gfc_post_options. */
135 gfc_option
.flag_max_stack_var_size
= -2;
136 gfc_option
.flag_stack_arrays
= -1;
138 gfc_option
.flag_range_check
= 1;
139 gfc_option
.flag_pack_derived
= 0;
140 gfc_option
.flag_repack_arrays
= 0;
141 gfc_option
.flag_preprocessed
= 0;
142 gfc_option
.flag_automatic
= 1;
143 gfc_option
.flag_backslash
= 0;
144 gfc_option
.flag_module_private
= 0;
145 gfc_option
.flag_backtrace
= 1;
146 gfc_option
.flag_allow_leading_underscore
= 0;
147 gfc_option
.flag_external_blas
= 0;
148 gfc_option
.blas_matmul_limit
= 30;
149 gfc_option
.flag_cray_pointer
= 0;
150 gfc_option
.flag_d_lines
= -1;
151 gfc_option
.gfc_flag_openmp
= 0;
152 gfc_option
.flag_sign_zero
= 1;
153 gfc_option
.flag_recursive
= 0;
154 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_OFF
;
155 gfc_option
.flag_init_integer_value
= 0;
156 gfc_option
.flag_init_real
= GFC_INIT_REAL_OFF
;
157 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_OFF
;
158 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_OFF
;
159 gfc_option
.flag_init_character_value
= (char)0;
160 gfc_option
.flag_align_commons
= 1;
161 gfc_option
.flag_protect_parens
= -1;
162 gfc_option
.flag_realloc_lhs
= -1;
163 gfc_option
.flag_aggressive_function_elimination
= 0;
164 gfc_option
.flag_frontend_optimize
= -1;
167 /* All except GFC_FPE_INEXACT. */
168 gfc_option
.fpe_summary
= GFC_FPE_INVALID
| GFC_FPE_DENORMAL
169 | GFC_FPE_ZERO
| GFC_FPE_OVERFLOW
171 gfc_option
.rtcheck
= 0;
172 gfc_option
.coarray
= GFC_FCOARRAY_NONE
;
174 /* ??? Wmissing-include-dirs is disabled by default in C/C++ but
175 enabled by default in Fortran. Ideally, we should express this
176 in .opt, but that is not supported yet. */
177 if (!global_options_set
.x_cpp_warn_missing_include_dirs
)
178 global_options
.x_cpp_warn_missing_include_dirs
= 1;;
180 set_default_std_flags ();
182 /* Initialize cpp-related options. */
183 gfc_cpp_init_options (decoded_options_count
, decoded_options
);
184 gfc_diagnostics_init ();
188 /* Determine the source form from the filename extension. We assume
189 case insensitivity. */
191 static gfc_source_form
192 form_from_filename (const char *filename
)
196 const char *extension
;
197 gfc_source_form form
;
224 }; /* sentinel value */
226 gfc_source_form f_form
;
230 /* Find end of file name. Note, filename is either a NULL pointer or
231 a NUL terminated string. */
233 while (filename
[i
] != '\0')
236 /* Find last period. */
237 while (i
>= 0 && (filename
[i
] != '.'))
240 /* Did we see a file extension? */
242 return FORM_UNKNOWN
; /* Nope */
244 /* Get file extension and compare it to others. */
245 fileext
= &(filename
[i
]);
248 f_form
= FORM_UNKNOWN
;
252 if (strcasecmp (fileext
, exttype
[i
].extension
) == 0)
254 f_form
= exttype
[i
].form
;
258 while (exttype
[i
].form
!= FORM_UNKNOWN
);
264 /* Finalize commandline options. */
267 gfc_post_options (const char **pfilename
)
269 const char *filename
= *pfilename
, *canon_source_file
= NULL
;
273 /* Excess precision other than "fast" requires front-end
275 if (flag_excess_precision_cmdline
== EXCESS_PRECISION_STANDARD
276 && TARGET_FLT_EVAL_METHOD_NON_DEFAULT
)
277 sorry ("-fexcess-precision=standard for Fortran");
278 flag_excess_precision_cmdline
= EXCESS_PRECISION_FAST
;
280 /* Fortran allows associative math - but we cannot reassociate if
281 we want traps or signed zeros. Cf. also flag_protect_parens. */
282 if (flag_associative_math
== -1)
283 flag_associative_math
= (!flag_trapping_math
&& !flag_signed_zeros
);
285 if (gfc_option
.flag_protect_parens
== -1)
286 gfc_option
.flag_protect_parens
= !optimize_fast
;
288 if (gfc_option
.flag_stack_arrays
== -1)
289 gfc_option
.flag_stack_arrays
= optimize_fast
;
291 /* By default, disable (re)allocation during assignment for -std=f95,
292 and enable it for F2003/F2008/GNU/Legacy. */
293 if (gfc_option
.flag_realloc_lhs
== -1)
295 if (gfc_option
.allow_std
& GFC_STD_F2003
)
296 gfc_option
.flag_realloc_lhs
= 1;
298 gfc_option
.flag_realloc_lhs
= 0;
301 /* -fbounds-check is equivalent to -fcheck=bounds */
302 if (flag_bounds_check
)
303 gfc_option
.rtcheck
|= GFC_RTCHECK_BOUNDS
;
305 if (flag_compare_debug
)
306 gfc_option
.dump_fortran_original
= 0;
308 /* Make -fmax-errors visible to gfortran's diagnostic machinery. */
309 if (global_options_set
.x_flag_max_errors
)
310 gfc_option
.max_errors
= flag_max_errors
;
312 /* Verify the input file name. */
313 if (!filename
|| strcmp (filename
, "-") == 0)
318 if (gfc_option
.flag_preprocessed
)
320 /* For preprocessed files, if the first tokens are of the form # NUM.
321 handle the directives so we know the original file name. */
322 gfc_source_file
= gfc_read_orig_filename (filename
, &canon_source_file
);
323 if (gfc_source_file
== NULL
)
324 gfc_source_file
= filename
;
326 *pfilename
= gfc_source_file
;
329 gfc_source_file
= filename
;
331 if (canon_source_file
== NULL
)
332 canon_source_file
= gfc_source_file
;
334 /* Adds the path where the source file is to the list of include files. */
336 i
= strlen (canon_source_file
);
337 while (i
> 0 && !IS_DIR_SEPARATOR (canon_source_file
[i
]))
342 source_path
= (char *) alloca (i
+ 1);
343 memcpy (source_path
, canon_source_file
, i
);
345 gfc_add_include_path (source_path
, true, true, true);
348 gfc_add_include_path (".", true, true, true);
350 if (canon_source_file
!= gfc_source_file
)
351 free (CONST_CAST (char *, canon_source_file
));
353 /* Decide which form the file will be read in as. */
355 if (gfc_option
.source_form
!= FORM_UNKNOWN
)
356 gfc_current_form
= gfc_option
.source_form
;
359 gfc_current_form
= form_from_filename (filename
);
361 if (gfc_current_form
== FORM_UNKNOWN
)
363 gfc_current_form
= FORM_FREE
;
364 gfc_warning_now_2 ("Reading file %qs as free form",
365 (filename
[0] == '\0') ? "<stdin>" : filename
);
369 /* If the user specified -fd-lines-as-{code|comments} verify that we're
371 if (gfc_current_form
== FORM_FREE
)
373 if (gfc_option
.flag_d_lines
== 0)
374 gfc_warning_now_2 ("%<-fd-lines-as-comments%> has no effect "
376 else if (gfc_option
.flag_d_lines
== 1)
377 gfc_warning_now_2 ("%<-fd-lines-as-code%> has no effect in free form");
380 /* If -pedantic, warn about the use of GNU extensions. */
381 if (pedantic
&& (gfc_option
.allow_std
& GFC_STD_GNU
) != 0)
382 gfc_option
.warn_std
|= GFC_STD_GNU
;
383 /* -std=legacy -pedantic is effectively -std=gnu. */
384 if (pedantic
&& (gfc_option
.allow_std
& GFC_STD_LEGACY
) != 0)
385 gfc_option
.warn_std
|= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
| GFC_STD_LEGACY
;
387 /* If the user didn't explicitly specify -f(no)-second-underscore we
388 use it if we're trying to be compatible with f2c, and not
390 if (gfc_option
.flag_second_underscore
== -1)
391 gfc_option
.flag_second_underscore
= gfc_option
.flag_f2c
;
393 if (!gfc_option
.flag_automatic
&& gfc_option
.flag_max_stack_var_size
!= -2
394 && gfc_option
.flag_max_stack_var_size
!= 0)
395 gfc_warning_now_2 ("Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
396 gfc_option
.flag_max_stack_var_size
);
397 else if (!gfc_option
.flag_automatic
&& gfc_option
.flag_recursive
)
398 gfc_warning_now_2 ("Flag %<-fno-automatic%> overwrites %<-frecursive%>");
399 else if (!gfc_option
.flag_automatic
&& gfc_option
.gfc_flag_openmp
)
400 gfc_warning_now_2 ("Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
402 else if (gfc_option
.flag_max_stack_var_size
!= -2
403 && gfc_option
.flag_recursive
)
404 gfc_warning_now_2 ("Flag %<-frecursive%> overwrites %<-fmax-stack-var-size=%d%>",
405 gfc_option
.flag_max_stack_var_size
);
406 else if (gfc_option
.flag_max_stack_var_size
!= -2
407 && gfc_option
.gfc_flag_openmp
)
408 gfc_warning_now_2 ("Flag %<-fmax-stack-var-size=%d%> overwrites %<-frecursive%> "
409 "implied by %<-fopenmp%>",
410 gfc_option
.flag_max_stack_var_size
);
412 /* Implement -frecursive as -fmax-stack-var-size=-1. */
413 if (gfc_option
.flag_recursive
)
414 gfc_option
.flag_max_stack_var_size
= -1;
416 /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
417 if (gfc_option
.flag_max_stack_var_size
== -2 && gfc_option
.gfc_flag_openmp
418 && gfc_option
.flag_automatic
)
420 gfc_option
.flag_recursive
= 1;
421 gfc_option
.flag_max_stack_var_size
= -1;
425 if (gfc_option
.flag_max_stack_var_size
== -2)
426 gfc_option
.flag_max_stack_var_size
= 32768;
428 /* Implement -fno-automatic as -fmax-stack-var-size=0. */
429 if (!gfc_option
.flag_automatic
)
430 gfc_option
.flag_max_stack_var_size
= 0;
434 gfc_option
.warn_ampersand
= 1;
435 gfc_option
.warn_tabs
= 0;
438 /* Optimization implies front end optimization, unless the user
439 specified it directly. */
441 if (gfc_option
.flag_frontend_optimize
== -1)
442 gfc_option
.flag_frontend_optimize
= optimize
;
444 if (gfc_option
.warn_realloc_lhs_all
)
445 gfc_option
.warn_realloc_lhs
= 1;
447 gfc_cpp_post_options ();
449 return gfc_cpp_preprocess_only ();
453 /* Set the options for -Wall. */
456 set_Wall (int setting
)
458 gfc_option
.warn_aliasing
= setting
;
459 gfc_option
.warn_ampersand
= setting
;
460 gfc_option
.warn_c_binding_type
= setting
;
461 gfc_option
.gfc_warn_conversion
= setting
;
462 gfc_option
.warn_line_truncation
= setting
;
463 gfc_option
.warn_surprising
= setting
;
464 gfc_option
.warn_tabs
= !setting
;
465 gfc_option
.warn_underflow
= setting
;
466 gfc_option
.warn_intrinsic_shadow
= setting
;
467 gfc_option
.warn_intrinsics_std
= setting
;
468 gfc_option
.warn_character_truncation
= setting
;
469 gfc_option
.warn_real_q_constant
= setting
;
470 gfc_option
.warn_unused_dummy_argument
= setting
;
471 gfc_option
.warn_target_lifetime
= setting
;
472 gfc_option
.warn_zerotrip
= setting
;
474 warn_return_type
= setting
;
475 warn_uninitialized
= setting
;
476 warn_maybe_uninitialized
= setting
;
479 /* Set the options for -Wextra. */
482 set_Wextra (int setting
)
484 gfc_option
.warn_compare_reals
= setting
;
488 gfc_handle_module_path_options (const char *arg
)
491 if (gfc_option
.module_dir
!= NULL
)
492 gfc_fatal_error ("gfortran: Only one %<-J%> option allowed");
494 gfc_option
.module_dir
= XCNEWVEC (char, strlen (arg
) + 2);
495 strcpy (gfc_option
.module_dir
, arg
);
497 gfc_add_include_path (gfc_option
.module_dir
, true, false, true);
499 strcat (gfc_option
.module_dir
, "/");
503 /* Handle options -ffpe-trap= and -ffpe-summary=. */
506 gfc_handle_fpe_option (const char *arg
, bool trap
)
508 int result
, pos
= 0, n
;
509 /* precision is a backwards compatibility alias for inexact. */
510 static const char * const exception
[] = { "invalid", "denormal", "zero",
511 "overflow", "underflow",
512 "inexact", "precision", NULL
};
513 static const int opt_exception
[] = { GFC_FPE_INVALID
, GFC_FPE_DENORMAL
,
514 GFC_FPE_ZERO
, GFC_FPE_OVERFLOW
,
515 GFC_FPE_UNDERFLOW
, GFC_FPE_INEXACT
,
519 /* As the default for -ffpe-summary= is nonzero, set it to 0. */
521 gfc_option
.fpe_summary
= 0;
528 while (arg
[pos
] && arg
[pos
] != ',')
532 if (!trap
&& strncmp ("none", arg
, pos
) == 0)
534 gfc_option
.fpe_summary
= 0;
539 else if (!trap
&& strncmp ("all", arg
, pos
) == 0)
541 gfc_option
.fpe_summary
= GFC_FPE_INVALID
| GFC_FPE_DENORMAL
542 | GFC_FPE_ZERO
| GFC_FPE_OVERFLOW
543 | GFC_FPE_UNDERFLOW
| GFC_FPE_INEXACT
;
549 for (n
= 0; exception
[n
] != NULL
; n
++)
551 if (exception
[n
] && strncmp (exception
[n
], arg
, pos
) == 0)
554 gfc_option
.fpe
|= opt_exception
[n
];
556 gfc_option
.fpe_summary
|= opt_exception
[n
];
563 if (!result
&& !trap
)
564 gfc_fatal_error ("Argument to %<-ffpe-trap%> is not valid: %s", arg
);
566 gfc_fatal_error ("Argument to %<-ffpe-summary%> is not valid: %s", arg
);
573 gfc_handle_coarray_option (const char *arg
)
575 if (strcmp (arg
, "none") == 0)
576 gfc_option
.coarray
= GFC_FCOARRAY_NONE
;
577 else if (strcmp (arg
, "single") == 0)
578 gfc_option
.coarray
= GFC_FCOARRAY_SINGLE
;
579 else if (strcmp (arg
, "lib") == 0)
580 gfc_option
.coarray
= GFC_FCOARRAY_LIB
;
582 gfc_fatal_error ("Argument to %<-fcoarray%> is not valid: %s", arg
);
587 gfc_handle_runtime_check_option (const char *arg
)
589 int result
, pos
= 0, n
;
590 static const char * const optname
[] = { "all", "bounds", "array-temps",
591 "recursion", "do", "pointer",
593 static const int optmask
[] = { GFC_RTCHECK_ALL
, GFC_RTCHECK_BOUNDS
,
594 GFC_RTCHECK_ARRAY_TEMPS
,
595 GFC_RTCHECK_RECURSION
, GFC_RTCHECK_DO
,
596 GFC_RTCHECK_POINTER
, GFC_RTCHECK_MEM
,
604 while (arg
[pos
] && arg
[pos
] != ',')
608 for (n
= 0; optname
[n
] != NULL
; n
++)
610 if (optname
[n
] && strncmp (optname
[n
], arg
, pos
) == 0)
612 gfc_option
.rtcheck
|= optmask
[n
];
620 gfc_fatal_error ("Argument to %<-fcheck%> is not valid: %s", arg
);
625 /* Handle command-line options. Returns 0 if unrecognized, 1 if
626 recognized and handled. */
629 gfc_handle_option (size_t scode
, const char *arg
, int value
,
630 int kind ATTRIBUTE_UNUSED
, location_t loc ATTRIBUTE_UNUSED
,
631 const struct cl_option_handlers
*handlers ATTRIBUTE_UNUSED
)
634 enum opt_code code
= (enum opt_code
) scode
;
636 if (gfc_cpp_handle_option (scode
, arg
, value
) == 1)
642 if (cl_options
[code
].flags
& gfc_option_lang_mask ())
648 handle_generated_option (&global_options
, &global_options_set
,
649 OPT_Wunused
, NULL
, value
,
650 gfc_option_lang_mask (), kind
, loc
,
651 handlers
, global_dc
);
656 gfc_option
.warn_aliasing
= value
;
660 gfc_option
.warn_ampersand
= value
;
663 case OPT_Warray_temporaries
:
664 gfc_option
.warn_array_temp
= value
;
667 case OPT_Wc_binding_type
:
668 gfc_option
.warn_c_binding_type
= value
;
671 case OPT_Wcharacter_truncation
:
672 gfc_option
.warn_character_truncation
= value
;
675 case OPT_Wcompare_reals
:
676 gfc_option
.warn_compare_reals
= value
;
679 case OPT_Wconversion
:
680 gfc_option
.gfc_warn_conversion
= value
;
683 case OPT_Wconversion_extra
:
684 gfc_option
.warn_conversion_extra
= value
;
691 case OPT_Wfunction_elimination
:
692 gfc_option
.warn_function_elimination
= value
;
695 case OPT_Wimplicit_interface
:
696 gfc_option
.warn_implicit_interface
= value
;
699 case OPT_Wimplicit_procedure
:
700 gfc_option
.warn_implicit_procedure
= value
;
703 case OPT_Wline_truncation
:
704 gfc_option
.warn_line_truncation
= value
;
707 case OPT_Wrealloc_lhs
:
708 gfc_option
.warn_realloc_lhs
= value
;
711 case OPT_Wrealloc_lhs_all
:
712 gfc_option
.warn_realloc_lhs_all
= value
;
715 case OPT_Wreturn_type
:
716 warn_return_type
= value
;
719 case OPT_Wsurprising
:
720 gfc_option
.warn_surprising
= value
;
724 gfc_option
.warn_tabs
= value
;
727 case OPT_Wtarget_lifetime
:
728 gfc_option
.warn_target_lifetime
= value
;
732 gfc_option
.warn_underflow
= value
;
735 case OPT_Wintrinsic_shadow
:
736 gfc_option
.warn_intrinsic_shadow
= value
;
739 case OPT_Walign_commons
:
740 gfc_option
.warn_align_commons
= value
;
743 case OPT_Wreal_q_constant
:
744 gfc_option
.warn_real_q_constant
= value
;
747 case OPT_Wunused_dummy_argument
:
748 gfc_option
.warn_unused_dummy_argument
= value
;
752 gfc_option
.warn_zerotrip
= value
;
755 case OPT_fall_intrinsics
:
756 gfc_option
.flag_all_intrinsics
= 1;
760 gfc_option
.flag_automatic
= value
;
763 case OPT_fallow_leading_underscore
:
764 gfc_option
.flag_allow_leading_underscore
= value
;
768 gfc_option
.flag_backslash
= value
;
772 gfc_option
.flag_backtrace
= value
;
775 case OPT_fcheck_array_temporaries
:
776 gfc_option
.rtcheck
|= GFC_RTCHECK_ARRAY_TEMPS
;
779 case OPT_fcray_pointer
:
780 gfc_option
.flag_cray_pointer
= value
;
784 gfc_option
.flag_f2c
= value
;
788 gfc_option
.flag_dollar_ok
= value
;
791 case OPT_fexternal_blas
:
792 gfc_option
.flag_external_blas
= value
;
795 case OPT_fblas_matmul_limit_
:
796 gfc_option
.blas_matmul_limit
= value
;
799 case OPT_fd_lines_as_code
:
800 gfc_option
.flag_d_lines
= 1;
803 case OPT_fd_lines_as_comments
:
804 gfc_option
.flag_d_lines
= 0;
807 case OPT_fdump_fortran_original
:
808 case OPT_fdump_parse_tree
:
809 gfc_option
.dump_fortran_original
= value
;
812 case OPT_fdump_fortran_optimized
:
813 gfc_option
.dump_fortran_optimized
= value
;
816 case OPT_ffixed_form
:
817 gfc_option
.source_form
= FORM_FIXED
;
820 case OPT_ffixed_line_length_none
:
821 gfc_option
.fixed_line_length
= 0;
824 case OPT_ffixed_line_length_
:
825 if (value
!= 0 && value
< 7)
826 gfc_fatal_error ("Fixed line length must be at least seven");
827 gfc_option
.fixed_line_length
= value
;
831 gfc_option
.source_form
= FORM_FREE
;
835 gfc_option
.gfc_flag_openmp
= value
;
838 case OPT_fopenmp_simd
:
839 gfc_option
.gfc_flag_openmp_simd
= value
;
842 case OPT_ffree_line_length_none
:
843 gfc_option
.free_line_length
= 0;
846 case OPT_ffree_line_length_
:
847 if (value
!= 0 && value
< 4)
848 gfc_fatal_error ("Free line length must be at least three");
849 gfc_option
.free_line_length
= value
;
852 case OPT_funderscoring
:
853 gfc_option
.flag_underscoring
= value
;
856 case OPT_fsecond_underscore
:
857 gfc_option
.flag_second_underscore
= value
;
860 case OPT_static_libgfortran
:
861 #ifndef HAVE_LD_STATIC_DYNAMIC
862 gfc_fatal_error ("%<-static-libgfortran%> is not supported in this "
867 case OPT_fimplicit_none
:
868 gfc_option
.flag_implicit_none
= value
;
871 case OPT_fintrinsic_modules_path
:
872 case OPT_fintrinsic_modules_path_
:
874 /* This is needed because omp_lib.h is in a directory together
875 with intrinsic modules. Do no warn because during testing
876 without an installed compiler, we would get lots of bogus
877 warnings for a missing include directory. */
878 gfc_add_include_path (arg
, false, false, false);
880 gfc_add_intrinsic_modules_path (arg
);
883 case OPT_fmax_array_constructor_
:
884 gfc_option
.flag_max_array_constructor
= value
> 65535 ? value
: 65535;
887 case OPT_fmax_stack_var_size_
:
888 gfc_option
.flag_max_stack_var_size
= value
;
891 case OPT_fstack_arrays
:
892 gfc_option
.flag_stack_arrays
= value
;
895 case OPT_fmodule_private
:
896 gfc_option
.flag_module_private
= value
;
899 case OPT_frange_check
:
900 gfc_option
.flag_range_check
= value
;
903 case OPT_fpack_derived
:
904 gfc_option
.flag_pack_derived
= value
;
907 case OPT_frepack_arrays
:
908 gfc_option
.flag_repack_arrays
= value
;
911 case OPT_fpreprocessed
:
912 gfc_option
.flag_preprocessed
= value
;
915 case OPT_fmax_identifier_length_
:
916 if (value
> GFC_MAX_SYMBOL_LEN
)
917 gfc_fatal_error ("Maximum supported identifier length is %d",
919 gfc_option
.max_identifier_length
= value
;
922 case OPT_fdefault_integer_8
:
923 gfc_option
.flag_default_integer
= value
;
926 case OPT_fdefault_real_8
:
927 gfc_option
.flag_default_real
= value
;
930 case OPT_fdefault_double_8
:
931 gfc_option
.flag_default_double
= value
;
934 case OPT_finteger_4_integer_8
:
935 gfc_option
.flag_integer4_kind
= 8;
938 case OPT_freal_4_real_8
:
939 gfc_option
.flag_real4_kind
= 8;
942 case OPT_freal_4_real_10
:
943 gfc_option
.flag_real4_kind
= 10;
946 case OPT_freal_4_real_16
:
947 gfc_option
.flag_real4_kind
= 16;
950 case OPT_freal_8_real_4
:
951 gfc_option
.flag_real8_kind
= 4;
954 case OPT_freal_8_real_10
:
955 gfc_option
.flag_real8_kind
= 10;
958 case OPT_freal_8_real_16
:
959 gfc_option
.flag_real8_kind
= 16;
962 case OPT_finit_local_zero
:
963 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_ON
;
964 gfc_option
.flag_init_integer_value
= 0;
965 gfc_option
.flag_init_real
= GFC_INIT_REAL_ZERO
;
966 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_FALSE
;
967 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_ON
;
968 gfc_option
.flag_init_character_value
= (char)0;
971 case OPT_finit_logical_
:
972 if (!strcasecmp (arg
, "false"))
973 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_FALSE
;
974 else if (!strcasecmp (arg
, "true"))
975 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_TRUE
;
977 gfc_fatal_error ("Unrecognized option to %<-finit-logical%>: %s",
981 case OPT_finit_real_
:
982 if (!strcasecmp (arg
, "zero"))
983 gfc_option
.flag_init_real
= GFC_INIT_REAL_ZERO
;
984 else if (!strcasecmp (arg
, "nan"))
985 gfc_option
.flag_init_real
= GFC_INIT_REAL_NAN
;
986 else if (!strcasecmp (arg
, "snan"))
987 gfc_option
.flag_init_real
= GFC_INIT_REAL_SNAN
;
988 else if (!strcasecmp (arg
, "inf"))
989 gfc_option
.flag_init_real
= GFC_INIT_REAL_INF
;
990 else if (!strcasecmp (arg
, "-inf"))
991 gfc_option
.flag_init_real
= GFC_INIT_REAL_NEG_INF
;
993 gfc_fatal_error ("Unrecognized option to %<-finit-real%>: %s",
997 case OPT_finit_integer_
:
998 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_ON
;
999 gfc_option
.flag_init_integer_value
= atoi (arg
);
1002 case OPT_finit_character_
:
1003 if (value
>= 0 && value
<= 127)
1005 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_ON
;
1006 gfc_option
.flag_init_character_value
= (char)value
;
1009 gfc_fatal_error ("The value of n in %<-finit-character=n%> must be "
1010 "between 0 and 127");
1014 gfc_add_include_path (arg
, true, false, true);
1018 gfc_handle_module_path_options (arg
);
1021 case OPT_fsign_zero
:
1022 gfc_option
.flag_sign_zero
= value
;
1025 case OPT_ffpe_trap_
:
1026 gfc_handle_fpe_option (arg
, true);
1029 case OPT_ffpe_summary_
:
1030 gfc_handle_fpe_option (arg
, false);
1034 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F95
| GFC_STD_F77
1035 | GFC_STD_F2008_OBS
;
1036 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
1037 gfc_option
.max_continue_fixed
= 19;
1038 gfc_option
.max_continue_free
= 39;
1039 gfc_option
.max_identifier_length
= 31;
1040 gfc_option
.warn_ampersand
= 1;
1041 gfc_option
.warn_tabs
= 0;
1045 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
1046 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008_OBS
;
1047 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
1048 gfc_option
.max_identifier_length
= 63;
1049 gfc_option
.warn_ampersand
= 1;
1050 gfc_option
.warn_tabs
= 0;
1054 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
1055 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008
| GFC_STD_F2008_OBS
;
1056 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2008_OBS
;
1057 gfc_option
.max_identifier_length
= 63;
1058 gfc_option
.warn_ampersand
= 1;
1059 gfc_option
.warn_tabs
= 0;
1062 case OPT_std_f2008ts
:
1063 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
1064 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008
| GFC_STD_F2008_OBS
1066 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2008_OBS
;
1067 gfc_option
.max_identifier_length
= 63;
1068 gfc_option
.warn_ampersand
= 1;
1069 gfc_option
.warn_tabs
= 0;
1073 set_default_std_flags ();
1076 case OPT_std_legacy
:
1077 set_default_std_flags ();
1078 gfc_option
.warn_std
= 0;
1081 case OPT_Wintrinsics_std
:
1082 gfc_option
.warn_intrinsics_std
= value
;
1085 case OPT_fshort_enums
:
1086 /* Handled in language-independent code. */
1089 case OPT_fconvert_little_endian
:
1090 gfc_option
.convert
= GFC_CONVERT_LITTLE
;
1093 case OPT_fconvert_big_endian
:
1094 gfc_option
.convert
= GFC_CONVERT_BIG
;
1097 case OPT_fconvert_native
:
1098 gfc_option
.convert
= GFC_CONVERT_NATIVE
;
1101 case OPT_fconvert_swap
:
1102 gfc_option
.convert
= GFC_CONVERT_SWAP
;
1105 case OPT_frecord_marker_4
:
1106 gfc_option
.record_marker
= 4;
1109 case OPT_frecord_marker_8
:
1110 gfc_option
.record_marker
= 8;
1113 case OPT_fmax_subrecord_length_
:
1114 if (value
> MAX_SUBRECORD_LENGTH
)
1115 gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
1116 MAX_SUBRECORD_LENGTH
);
1118 gfc_option
.max_subrecord_length
= value
;
1121 case OPT_frecursive
:
1122 gfc_option
.flag_recursive
= value
;
1125 case OPT_falign_commons
:
1126 gfc_option
.flag_align_commons
= value
;
1129 case OPT_faggressive_function_elimination
:
1130 gfc_option
.flag_aggressive_function_elimination
= value
;
1133 case OPT_ffrontend_optimize
:
1134 gfc_option
.flag_frontend_optimize
= value
;
1137 case OPT_fprotect_parens
:
1138 gfc_option
.flag_protect_parens
= value
;
1141 case OPT_frealloc_lhs
:
1142 gfc_option
.flag_realloc_lhs
= value
;
1146 gfc_handle_runtime_check_option (arg
);
1150 gfc_handle_coarray_option (arg
);
1154 Fortran_handle_option_auto (&global_options
, &global_options_set
,
1156 gfc_option_lang_mask (), kind
,
1157 loc
, handlers
, global_dc
);
1162 /* Return a string with the options passed to the compiler; used for
1163 Fortran's compiler_options() intrinsic. */
1166 gfc_get_option_string (void)
1172 /* Allocate and return a one-character string with '\0'. */
1173 if (!save_decoded_options_count
)
1174 return XCNEWVEC (char, 1);
1176 /* Determine required string length. */
1179 for (j
= 1; j
< save_decoded_options_count
; j
++)
1181 switch (save_decoded_options
[j
].opt_index
)
1190 case OPT_fintrinsic_modules_path
:
1191 case OPT_fintrinsic_modules_path_
:
1195 /* Ignore file names. */
1196 if (save_decoded_options
[j
].orig_option_with_args_text
[0] == '-')
1198 + strlen (save_decoded_options
[j
].orig_option_with_args_text
);
1202 result
= XCNEWVEC (char, len
);
1205 for (j
= 1; j
< save_decoded_options_count
; j
++)
1207 switch (save_decoded_options
[j
].opt_index
)
1216 case OPT_fintrinsic_modules_path
:
1217 case OPT_fintrinsic_modules_path_
:
1222 /* Use "-cpp" rather than "-cpp=<temporary file>". */
1227 /* Ignore file names. */
1228 if (save_decoded_options
[j
].orig_option_with_args_text
[0] != '-')
1231 len
= strlen (save_decoded_options
[j
].orig_option_with_args_text
);
1234 memcpy (&result
[pos
], save_decoded_options
[j
].orig_option_with_args_text
, len
);
1236 result
[pos
++] = ' ';
1239 result
[--pos
] = '\0';