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_array_temp
= 0;
99 gfc_option
.warn_c_binding_type
= 0;
100 gfc_option
.gfc_warn_conversion
= 0;
101 gfc_option
.warn_conversion_extra
= 0;
102 gfc_option
.warn_function_elimination
= 0;
103 gfc_option
.warn_implicit_interface
= 0;
104 gfc_option
.warn_line_truncation
= 0;
105 gfc_option
.warn_surprising
= 0;
106 gfc_option
.warn_underflow
= 1;
107 gfc_option
.warn_intrinsic_shadow
= 0;
108 gfc_option
.warn_intrinsics_std
= 0;
109 gfc_option
.warn_align_commons
= 1;
110 gfc_option
.warn_real_q_constant
= 0;
111 gfc_option
.warn_unused_dummy_argument
= 0;
112 gfc_option
.warn_zerotrip
= 0;
113 gfc_option
.warn_realloc_lhs
= 0;
114 gfc_option
.warn_realloc_lhs_all
= 0;
115 gfc_option
.warn_compare_reals
= 0;
116 gfc_option
.warn_target_lifetime
= 0;
117 gfc_option
.max_errors
= 25;
119 gfc_option
.flag_all_intrinsics
= 0;
120 gfc_option
.flag_default_double
= 0;
121 gfc_option
.flag_default_integer
= 0;
122 gfc_option
.flag_default_real
= 0;
123 gfc_option
.flag_integer4_kind
= 0;
124 gfc_option
.flag_real4_kind
= 0;
125 gfc_option
.flag_real8_kind
= 0;
126 gfc_option
.flag_dollar_ok
= 0;
127 gfc_option
.flag_underscoring
= 1;
128 gfc_option
.flag_f2c
= 0;
129 gfc_option
.flag_second_underscore
= -1;
130 gfc_option
.flag_implicit_none
= 0;
132 /* Default value of flag_max_stack_var_size is set in gfc_post_options. */
133 gfc_option
.flag_max_stack_var_size
= -2;
134 gfc_option
.flag_stack_arrays
= -1;
136 gfc_option
.flag_range_check
= 1;
137 gfc_option
.flag_pack_derived
= 0;
138 gfc_option
.flag_repack_arrays
= 0;
139 gfc_option
.flag_preprocessed
= 0;
140 gfc_option
.flag_automatic
= 1;
141 gfc_option
.flag_backslash
= 0;
142 gfc_option
.flag_module_private
= 0;
143 gfc_option
.flag_backtrace
= 1;
144 gfc_option
.flag_allow_leading_underscore
= 0;
145 gfc_option
.flag_external_blas
= 0;
146 gfc_option
.blas_matmul_limit
= 30;
147 gfc_option
.flag_cray_pointer
= 0;
148 gfc_option
.flag_d_lines
= -1;
149 gfc_option
.gfc_flag_openmp
= 0;
150 gfc_option
.flag_sign_zero
= 1;
151 gfc_option
.flag_recursive
= 0;
152 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_OFF
;
153 gfc_option
.flag_init_integer_value
= 0;
154 gfc_option
.flag_init_real
= GFC_INIT_REAL_OFF
;
155 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_OFF
;
156 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_OFF
;
157 gfc_option
.flag_init_character_value
= (char)0;
158 gfc_option
.flag_align_commons
= 1;
159 gfc_option
.flag_protect_parens
= -1;
160 gfc_option
.flag_realloc_lhs
= -1;
161 gfc_option
.flag_aggressive_function_elimination
= 0;
162 gfc_option
.flag_frontend_optimize
= -1;
165 /* All except GFC_FPE_INEXACT. */
166 gfc_option
.fpe_summary
= GFC_FPE_INVALID
| GFC_FPE_DENORMAL
167 | GFC_FPE_ZERO
| GFC_FPE_OVERFLOW
169 gfc_option
.rtcheck
= 0;
170 gfc_option
.coarray
= GFC_FCOARRAY_NONE
;
172 /* ??? Wmissing-include-dirs is disabled by default in C/C++ but
173 enabled by default in Fortran. Ideally, we should express this
174 in .opt, but that is not supported yet. */
175 if (!global_options_set
.x_cpp_warn_missing_include_dirs
)
176 global_options
.x_cpp_warn_missing_include_dirs
= 1;;
178 set_default_std_flags ();
180 /* Initialize cpp-related options. */
181 gfc_cpp_init_options (decoded_options_count
, decoded_options
);
182 gfc_diagnostics_init ();
186 /* Determine the source form from the filename extension. We assume
187 case insensitivity. */
189 static gfc_source_form
190 form_from_filename (const char *filename
)
194 const char *extension
;
195 gfc_source_form form
;
222 }; /* sentinel value */
224 gfc_source_form f_form
;
228 /* Find end of file name. Note, filename is either a NULL pointer or
229 a NUL terminated string. */
231 while (filename
[i
] != '\0')
234 /* Find last period. */
235 while (i
>= 0 && (filename
[i
] != '.'))
238 /* Did we see a file extension? */
240 return FORM_UNKNOWN
; /* Nope */
242 /* Get file extension and compare it to others. */
243 fileext
= &(filename
[i
]);
246 f_form
= FORM_UNKNOWN
;
250 if (strcasecmp (fileext
, exttype
[i
].extension
) == 0)
252 f_form
= exttype
[i
].form
;
256 while (exttype
[i
].form
!= FORM_UNKNOWN
);
262 /* Finalize commandline options. */
265 gfc_post_options (const char **pfilename
)
267 const char *filename
= *pfilename
, *canon_source_file
= NULL
;
271 /* Excess precision other than "fast" requires front-end
273 if (flag_excess_precision_cmdline
== EXCESS_PRECISION_STANDARD
274 && TARGET_FLT_EVAL_METHOD_NON_DEFAULT
)
275 sorry ("-fexcess-precision=standard for Fortran");
276 flag_excess_precision_cmdline
= EXCESS_PRECISION_FAST
;
278 /* Fortran allows associative math - but we cannot reassociate if
279 we want traps or signed zeros. Cf. also flag_protect_parens. */
280 if (flag_associative_math
== -1)
281 flag_associative_math
= (!flag_trapping_math
&& !flag_signed_zeros
);
283 if (gfc_option
.flag_protect_parens
== -1)
284 gfc_option
.flag_protect_parens
= !optimize_fast
;
286 if (gfc_option
.flag_stack_arrays
== -1)
287 gfc_option
.flag_stack_arrays
= optimize_fast
;
289 /* By default, disable (re)allocation during assignment for -std=f95,
290 and enable it for F2003/F2008/GNU/Legacy. */
291 if (gfc_option
.flag_realloc_lhs
== -1)
293 if (gfc_option
.allow_std
& GFC_STD_F2003
)
294 gfc_option
.flag_realloc_lhs
= 1;
296 gfc_option
.flag_realloc_lhs
= 0;
299 /* -fbounds-check is equivalent to -fcheck=bounds */
300 if (flag_bounds_check
)
301 gfc_option
.rtcheck
|= GFC_RTCHECK_BOUNDS
;
303 if (flag_compare_debug
)
304 gfc_option
.dump_fortran_original
= 0;
306 /* Make -fmax-errors visible to gfortran's diagnostic machinery. */
307 if (global_options_set
.x_flag_max_errors
)
308 gfc_option
.max_errors
= flag_max_errors
;
310 /* Verify the input file name. */
311 if (!filename
|| strcmp (filename
, "-") == 0)
316 if (gfc_option
.flag_preprocessed
)
318 /* For preprocessed files, if the first tokens are of the form # NUM.
319 handle the directives so we know the original file name. */
320 gfc_source_file
= gfc_read_orig_filename (filename
, &canon_source_file
);
321 if (gfc_source_file
== NULL
)
322 gfc_source_file
= filename
;
324 *pfilename
= gfc_source_file
;
327 gfc_source_file
= filename
;
329 if (canon_source_file
== NULL
)
330 canon_source_file
= gfc_source_file
;
332 /* Adds the path where the source file is to the list of include files. */
334 i
= strlen (canon_source_file
);
335 while (i
> 0 && !IS_DIR_SEPARATOR (canon_source_file
[i
]))
340 source_path
= (char *) alloca (i
+ 1);
341 memcpy (source_path
, canon_source_file
, i
);
343 gfc_add_include_path (source_path
, true, true, true);
346 gfc_add_include_path (".", true, true, true);
348 if (canon_source_file
!= gfc_source_file
)
349 free (CONST_CAST (char *, canon_source_file
));
351 /* Decide which form the file will be read in as. */
353 if (gfc_option
.source_form
!= FORM_UNKNOWN
)
354 gfc_current_form
= gfc_option
.source_form
;
357 gfc_current_form
= form_from_filename (filename
);
359 if (gfc_current_form
== FORM_UNKNOWN
)
361 gfc_current_form
= FORM_FREE
;
362 gfc_warning_now_2 ("Reading file %qs as free form",
363 (filename
[0] == '\0') ? "<stdin>" : filename
);
367 /* If the user specified -fd-lines-as-{code|comments} verify that we're
369 if (gfc_current_form
== FORM_FREE
)
371 if (gfc_option
.flag_d_lines
== 0)
372 gfc_warning_now_2 ("%<-fd-lines-as-comments%> has no effect "
374 else if (gfc_option
.flag_d_lines
== 1)
375 gfc_warning_now_2 ("%<-fd-lines-as-code%> has no effect in free form");
378 /* If -pedantic, warn about the use of GNU extensions. */
379 if (pedantic
&& (gfc_option
.allow_std
& GFC_STD_GNU
) != 0)
380 gfc_option
.warn_std
|= GFC_STD_GNU
;
381 /* -std=legacy -pedantic is effectively -std=gnu. */
382 if (pedantic
&& (gfc_option
.allow_std
& GFC_STD_LEGACY
) != 0)
383 gfc_option
.warn_std
|= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
| GFC_STD_LEGACY
;
385 /* If the user didn't explicitly specify -f(no)-second-underscore we
386 use it if we're trying to be compatible with f2c, and not
388 if (gfc_option
.flag_second_underscore
== -1)
389 gfc_option
.flag_second_underscore
= gfc_option
.flag_f2c
;
391 if (!gfc_option
.flag_automatic
&& gfc_option
.flag_max_stack_var_size
!= -2
392 && gfc_option
.flag_max_stack_var_size
!= 0)
393 gfc_warning_now_2 ("Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
394 gfc_option
.flag_max_stack_var_size
);
395 else if (!gfc_option
.flag_automatic
&& gfc_option
.flag_recursive
)
396 gfc_warning_now_2 ("Flag %<-fno-automatic%> overwrites %<-frecursive%>");
397 else if (!gfc_option
.flag_automatic
&& gfc_option
.gfc_flag_openmp
)
398 gfc_warning_now_2 ("Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
400 else if (gfc_option
.flag_max_stack_var_size
!= -2
401 && gfc_option
.flag_recursive
)
402 gfc_warning_now_2 ("Flag %<-frecursive%> overwrites %<-fmax-stack-var-size=%d%>",
403 gfc_option
.flag_max_stack_var_size
);
404 else if (gfc_option
.flag_max_stack_var_size
!= -2
405 && gfc_option
.gfc_flag_openmp
)
406 gfc_warning_now_2 ("Flag %<-fmax-stack-var-size=%d%> overwrites %<-frecursive%> "
407 "implied by %<-fopenmp%>",
408 gfc_option
.flag_max_stack_var_size
);
410 /* Implement -frecursive as -fmax-stack-var-size=-1. */
411 if (gfc_option
.flag_recursive
)
412 gfc_option
.flag_max_stack_var_size
= -1;
414 /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
415 if (gfc_option
.flag_max_stack_var_size
== -2 && gfc_option
.gfc_flag_openmp
416 && gfc_option
.flag_automatic
)
418 gfc_option
.flag_recursive
= 1;
419 gfc_option
.flag_max_stack_var_size
= -1;
423 if (gfc_option
.flag_max_stack_var_size
== -2)
424 gfc_option
.flag_max_stack_var_size
= 32768;
426 /* Implement -fno-automatic as -fmax-stack-var-size=0. */
427 if (!gfc_option
.flag_automatic
)
428 gfc_option
.flag_max_stack_var_size
= 0;
431 gfc_option
.warn_ampersand
= 1;
433 /* Optimization implies front end optimization, unless the user
434 specified it directly. */
436 if (gfc_option
.flag_frontend_optimize
== -1)
437 gfc_option
.flag_frontend_optimize
= optimize
;
439 if (gfc_option
.warn_realloc_lhs_all
)
440 gfc_option
.warn_realloc_lhs
= 1;
442 gfc_cpp_post_options ();
444 return gfc_cpp_preprocess_only ();
448 /* Set the options for -Wall. */
451 set_Wall (int setting
)
453 gfc_option
.warn_aliasing
= setting
;
454 gfc_option
.warn_ampersand
= setting
;
455 gfc_option
.warn_c_binding_type
= setting
;
456 gfc_option
.gfc_warn_conversion
= setting
;
457 gfc_option
.warn_line_truncation
= setting
;
458 gfc_option
.warn_surprising
= setting
;
459 gfc_option
.warn_underflow
= setting
;
460 gfc_option
.warn_intrinsic_shadow
= setting
;
461 gfc_option
.warn_intrinsics_std
= setting
;
462 gfc_option
.warn_real_q_constant
= setting
;
463 gfc_option
.warn_unused_dummy_argument
= setting
;
464 gfc_option
.warn_target_lifetime
= setting
;
465 gfc_option
.warn_zerotrip
= setting
;
467 warn_return_type
= setting
;
468 warn_uninitialized
= setting
;
469 warn_maybe_uninitialized
= setting
;
472 /* Set the options for -Wextra. */
475 set_Wextra (int setting
)
477 gfc_option
.warn_compare_reals
= setting
;
481 gfc_handle_module_path_options (const char *arg
)
484 if (gfc_option
.module_dir
!= NULL
)
485 gfc_fatal_error ("gfortran: Only one %<-J%> option allowed");
487 gfc_option
.module_dir
= XCNEWVEC (char, strlen (arg
) + 2);
488 strcpy (gfc_option
.module_dir
, arg
);
490 gfc_add_include_path (gfc_option
.module_dir
, true, false, true);
492 strcat (gfc_option
.module_dir
, "/");
496 /* Handle options -ffpe-trap= and -ffpe-summary=. */
499 gfc_handle_fpe_option (const char *arg
, bool trap
)
501 int result
, pos
= 0, n
;
502 /* precision is a backwards compatibility alias for inexact. */
503 static const char * const exception
[] = { "invalid", "denormal", "zero",
504 "overflow", "underflow",
505 "inexact", "precision", NULL
};
506 static const int opt_exception
[] = { GFC_FPE_INVALID
, GFC_FPE_DENORMAL
,
507 GFC_FPE_ZERO
, GFC_FPE_OVERFLOW
,
508 GFC_FPE_UNDERFLOW
, GFC_FPE_INEXACT
,
512 /* As the default for -ffpe-summary= is nonzero, set it to 0. */
514 gfc_option
.fpe_summary
= 0;
521 while (arg
[pos
] && arg
[pos
] != ',')
525 if (!trap
&& strncmp ("none", arg
, pos
) == 0)
527 gfc_option
.fpe_summary
= 0;
532 else if (!trap
&& strncmp ("all", arg
, pos
) == 0)
534 gfc_option
.fpe_summary
= GFC_FPE_INVALID
| GFC_FPE_DENORMAL
535 | GFC_FPE_ZERO
| GFC_FPE_OVERFLOW
536 | GFC_FPE_UNDERFLOW
| GFC_FPE_INEXACT
;
542 for (n
= 0; exception
[n
] != NULL
; n
++)
544 if (exception
[n
] && strncmp (exception
[n
], arg
, pos
) == 0)
547 gfc_option
.fpe
|= opt_exception
[n
];
549 gfc_option
.fpe_summary
|= opt_exception
[n
];
556 if (!result
&& !trap
)
557 gfc_fatal_error ("Argument to %<-ffpe-trap%> is not valid: %s", arg
);
559 gfc_fatal_error ("Argument to %<-ffpe-summary%> is not valid: %s", arg
);
566 gfc_handle_coarray_option (const char *arg
)
568 if (strcmp (arg
, "none") == 0)
569 gfc_option
.coarray
= GFC_FCOARRAY_NONE
;
570 else if (strcmp (arg
, "single") == 0)
571 gfc_option
.coarray
= GFC_FCOARRAY_SINGLE
;
572 else if (strcmp (arg
, "lib") == 0)
573 gfc_option
.coarray
= GFC_FCOARRAY_LIB
;
575 gfc_fatal_error ("Argument to %<-fcoarray%> is not valid: %s", arg
);
580 gfc_handle_runtime_check_option (const char *arg
)
582 int result
, pos
= 0, n
;
583 static const char * const optname
[] = { "all", "bounds", "array-temps",
584 "recursion", "do", "pointer",
586 static const int optmask
[] = { GFC_RTCHECK_ALL
, GFC_RTCHECK_BOUNDS
,
587 GFC_RTCHECK_ARRAY_TEMPS
,
588 GFC_RTCHECK_RECURSION
, GFC_RTCHECK_DO
,
589 GFC_RTCHECK_POINTER
, GFC_RTCHECK_MEM
,
597 while (arg
[pos
] && arg
[pos
] != ',')
601 for (n
= 0; optname
[n
] != NULL
; n
++)
603 if (optname
[n
] && strncmp (optname
[n
], arg
, pos
) == 0)
605 gfc_option
.rtcheck
|= optmask
[n
];
613 gfc_fatal_error ("Argument to %<-fcheck%> is not valid: %s", arg
);
618 /* Handle command-line options. Returns 0 if unrecognized, 1 if
619 recognized and handled. */
622 gfc_handle_option (size_t scode
, const char *arg
, int value
,
623 int kind ATTRIBUTE_UNUSED
, location_t loc ATTRIBUTE_UNUSED
,
624 const struct cl_option_handlers
*handlers ATTRIBUTE_UNUSED
)
627 enum opt_code code
= (enum opt_code
) scode
;
629 if (gfc_cpp_handle_option (scode
, arg
, value
) == 1)
635 if (cl_options
[code
].flags
& gfc_option_lang_mask ())
641 handle_generated_option (&global_options
, &global_options_set
,
642 OPT_Wunused
, NULL
, value
,
643 gfc_option_lang_mask (), kind
, loc
,
644 handlers
, global_dc
);
649 gfc_option
.warn_aliasing
= value
;
653 gfc_option
.warn_ampersand
= value
;
656 case OPT_Warray_temporaries
:
657 gfc_option
.warn_array_temp
= value
;
660 case OPT_Wc_binding_type
:
661 gfc_option
.warn_c_binding_type
= value
;
664 case OPT_Wcompare_reals
:
665 gfc_option
.warn_compare_reals
= value
;
668 case OPT_Wconversion
:
669 gfc_option
.gfc_warn_conversion
= value
;
672 case OPT_Wconversion_extra
:
673 gfc_option
.warn_conversion_extra
= value
;
680 case OPT_Wfunction_elimination
:
681 gfc_option
.warn_function_elimination
= value
;
684 case OPT_Wimplicit_interface
:
685 gfc_option
.warn_implicit_interface
= value
;
688 case OPT_Wimplicit_procedure
:
689 gfc_option
.warn_implicit_procedure
= value
;
692 case OPT_Wline_truncation
:
693 gfc_option
.warn_line_truncation
= value
;
696 case OPT_Wrealloc_lhs
:
697 gfc_option
.warn_realloc_lhs
= value
;
700 case OPT_Wrealloc_lhs_all
:
701 gfc_option
.warn_realloc_lhs_all
= value
;
704 case OPT_Wreturn_type
:
705 warn_return_type
= value
;
708 case OPT_Wsurprising
:
709 gfc_option
.warn_surprising
= value
;
712 case OPT_Wtarget_lifetime
:
713 gfc_option
.warn_target_lifetime
= value
;
717 gfc_option
.warn_underflow
= value
;
720 case OPT_Wintrinsic_shadow
:
721 gfc_option
.warn_intrinsic_shadow
= value
;
724 case OPT_Walign_commons
:
725 gfc_option
.warn_align_commons
= value
;
728 case OPT_Wreal_q_constant
:
729 gfc_option
.warn_real_q_constant
= value
;
732 case OPT_Wunused_dummy_argument
:
733 gfc_option
.warn_unused_dummy_argument
= value
;
737 gfc_option
.warn_zerotrip
= value
;
740 case OPT_fall_intrinsics
:
741 gfc_option
.flag_all_intrinsics
= 1;
745 gfc_option
.flag_automatic
= value
;
748 case OPT_fallow_leading_underscore
:
749 gfc_option
.flag_allow_leading_underscore
= value
;
753 gfc_option
.flag_backslash
= value
;
757 gfc_option
.flag_backtrace
= value
;
760 case OPT_fcheck_array_temporaries
:
761 gfc_option
.rtcheck
|= GFC_RTCHECK_ARRAY_TEMPS
;
764 case OPT_fcray_pointer
:
765 gfc_option
.flag_cray_pointer
= value
;
769 gfc_option
.flag_f2c
= value
;
773 gfc_option
.flag_dollar_ok
= value
;
776 case OPT_fexternal_blas
:
777 gfc_option
.flag_external_blas
= value
;
780 case OPT_fblas_matmul_limit_
:
781 gfc_option
.blas_matmul_limit
= value
;
784 case OPT_fd_lines_as_code
:
785 gfc_option
.flag_d_lines
= 1;
788 case OPT_fd_lines_as_comments
:
789 gfc_option
.flag_d_lines
= 0;
792 case OPT_fdump_fortran_original
:
793 case OPT_fdump_parse_tree
:
794 gfc_option
.dump_fortran_original
= value
;
797 case OPT_fdump_fortran_optimized
:
798 gfc_option
.dump_fortran_optimized
= value
;
801 case OPT_ffixed_form
:
802 gfc_option
.source_form
= FORM_FIXED
;
805 case OPT_ffixed_line_length_none
:
806 gfc_option
.fixed_line_length
= 0;
809 case OPT_ffixed_line_length_
:
810 if (value
!= 0 && value
< 7)
811 gfc_fatal_error ("Fixed line length must be at least seven");
812 gfc_option
.fixed_line_length
= value
;
816 gfc_option
.source_form
= FORM_FREE
;
820 gfc_option
.gfc_flag_openmp
= value
;
823 case OPT_fopenmp_simd
:
824 gfc_option
.gfc_flag_openmp_simd
= value
;
827 case OPT_ffree_line_length_none
:
828 gfc_option
.free_line_length
= 0;
831 case OPT_ffree_line_length_
:
832 if (value
!= 0 && value
< 4)
833 gfc_fatal_error ("Free line length must be at least three");
834 gfc_option
.free_line_length
= value
;
837 case OPT_funderscoring
:
838 gfc_option
.flag_underscoring
= value
;
841 case OPT_fsecond_underscore
:
842 gfc_option
.flag_second_underscore
= value
;
845 case OPT_static_libgfortran
:
846 #ifndef HAVE_LD_STATIC_DYNAMIC
847 gfc_fatal_error ("%<-static-libgfortran%> is not supported in this "
852 case OPT_fimplicit_none
:
853 gfc_option
.flag_implicit_none
= value
;
856 case OPT_fintrinsic_modules_path
:
857 case OPT_fintrinsic_modules_path_
:
859 /* This is needed because omp_lib.h is in a directory together
860 with intrinsic modules. Do no warn because during testing
861 without an installed compiler, we would get lots of bogus
862 warnings for a missing include directory. */
863 gfc_add_include_path (arg
, false, false, false);
865 gfc_add_intrinsic_modules_path (arg
);
868 case OPT_fmax_array_constructor_
:
869 gfc_option
.flag_max_array_constructor
= value
> 65535 ? value
: 65535;
872 case OPT_fmax_stack_var_size_
:
873 gfc_option
.flag_max_stack_var_size
= value
;
876 case OPT_fstack_arrays
:
877 gfc_option
.flag_stack_arrays
= value
;
880 case OPT_fmodule_private
:
881 gfc_option
.flag_module_private
= value
;
884 case OPT_frange_check
:
885 gfc_option
.flag_range_check
= value
;
888 case OPT_fpack_derived
:
889 gfc_option
.flag_pack_derived
= value
;
892 case OPT_frepack_arrays
:
893 gfc_option
.flag_repack_arrays
= value
;
896 case OPT_fpreprocessed
:
897 gfc_option
.flag_preprocessed
= value
;
900 case OPT_fmax_identifier_length_
:
901 if (value
> GFC_MAX_SYMBOL_LEN
)
902 gfc_fatal_error ("Maximum supported identifier length is %d",
904 gfc_option
.max_identifier_length
= value
;
907 case OPT_fdefault_integer_8
:
908 gfc_option
.flag_default_integer
= value
;
911 case OPT_fdefault_real_8
:
912 gfc_option
.flag_default_real
= value
;
915 case OPT_fdefault_double_8
:
916 gfc_option
.flag_default_double
= value
;
919 case OPT_finteger_4_integer_8
:
920 gfc_option
.flag_integer4_kind
= 8;
923 case OPT_freal_4_real_8
:
924 gfc_option
.flag_real4_kind
= 8;
927 case OPT_freal_4_real_10
:
928 gfc_option
.flag_real4_kind
= 10;
931 case OPT_freal_4_real_16
:
932 gfc_option
.flag_real4_kind
= 16;
935 case OPT_freal_8_real_4
:
936 gfc_option
.flag_real8_kind
= 4;
939 case OPT_freal_8_real_10
:
940 gfc_option
.flag_real8_kind
= 10;
943 case OPT_freal_8_real_16
:
944 gfc_option
.flag_real8_kind
= 16;
947 case OPT_finit_local_zero
:
948 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_ON
;
949 gfc_option
.flag_init_integer_value
= 0;
950 gfc_option
.flag_init_real
= GFC_INIT_REAL_ZERO
;
951 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_FALSE
;
952 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_ON
;
953 gfc_option
.flag_init_character_value
= (char)0;
956 case OPT_finit_logical_
:
957 if (!strcasecmp (arg
, "false"))
958 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_FALSE
;
959 else if (!strcasecmp (arg
, "true"))
960 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_TRUE
;
962 gfc_fatal_error ("Unrecognized option to %<-finit-logical%>: %s",
966 case OPT_finit_real_
:
967 if (!strcasecmp (arg
, "zero"))
968 gfc_option
.flag_init_real
= GFC_INIT_REAL_ZERO
;
969 else if (!strcasecmp (arg
, "nan"))
970 gfc_option
.flag_init_real
= GFC_INIT_REAL_NAN
;
971 else if (!strcasecmp (arg
, "snan"))
972 gfc_option
.flag_init_real
= GFC_INIT_REAL_SNAN
;
973 else if (!strcasecmp (arg
, "inf"))
974 gfc_option
.flag_init_real
= GFC_INIT_REAL_INF
;
975 else if (!strcasecmp (arg
, "-inf"))
976 gfc_option
.flag_init_real
= GFC_INIT_REAL_NEG_INF
;
978 gfc_fatal_error ("Unrecognized option to %<-finit-real%>: %s",
982 case OPT_finit_integer_
:
983 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_ON
;
984 gfc_option
.flag_init_integer_value
= atoi (arg
);
987 case OPT_finit_character_
:
988 if (value
>= 0 && value
<= 127)
990 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_ON
;
991 gfc_option
.flag_init_character_value
= (char)value
;
994 gfc_fatal_error ("The value of n in %<-finit-character=n%> must be "
995 "between 0 and 127");
999 gfc_add_include_path (arg
, true, false, true);
1003 gfc_handle_module_path_options (arg
);
1006 case OPT_fsign_zero
:
1007 gfc_option
.flag_sign_zero
= value
;
1010 case OPT_ffpe_trap_
:
1011 gfc_handle_fpe_option (arg
, true);
1014 case OPT_ffpe_summary_
:
1015 gfc_handle_fpe_option (arg
, false);
1019 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F95
| GFC_STD_F77
1020 | GFC_STD_F2008_OBS
;
1021 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
1022 gfc_option
.max_continue_fixed
= 19;
1023 gfc_option
.max_continue_free
= 39;
1024 gfc_option
.max_identifier_length
= 31;
1025 gfc_option
.warn_ampersand
= 1;
1030 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
1031 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008_OBS
;
1032 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
1033 gfc_option
.max_identifier_length
= 63;
1034 gfc_option
.warn_ampersand
= 1;
1039 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
1040 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008
| GFC_STD_F2008_OBS
;
1041 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2008_OBS
;
1042 gfc_option
.max_identifier_length
= 63;
1043 gfc_option
.warn_ampersand
= 1;
1047 case OPT_std_f2008ts
:
1048 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
1049 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008
| GFC_STD_F2008_OBS
1051 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2008_OBS
;
1052 gfc_option
.max_identifier_length
= 63;
1053 gfc_option
.warn_ampersand
= 1;
1058 set_default_std_flags ();
1061 case OPT_std_legacy
:
1062 set_default_std_flags ();
1063 gfc_option
.warn_std
= 0;
1066 case OPT_Wintrinsics_std
:
1067 gfc_option
.warn_intrinsics_std
= value
;
1070 case OPT_fshort_enums
:
1071 /* Handled in language-independent code. */
1074 case OPT_fconvert_little_endian
:
1075 gfc_option
.convert
= GFC_CONVERT_LITTLE
;
1078 case OPT_fconvert_big_endian
:
1079 gfc_option
.convert
= GFC_CONVERT_BIG
;
1082 case OPT_fconvert_native
:
1083 gfc_option
.convert
= GFC_CONVERT_NATIVE
;
1086 case OPT_fconvert_swap
:
1087 gfc_option
.convert
= GFC_CONVERT_SWAP
;
1090 case OPT_frecord_marker_4
:
1091 gfc_option
.record_marker
= 4;
1094 case OPT_frecord_marker_8
:
1095 gfc_option
.record_marker
= 8;
1098 case OPT_fmax_subrecord_length_
:
1099 if (value
> MAX_SUBRECORD_LENGTH
)
1100 gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
1101 MAX_SUBRECORD_LENGTH
);
1103 gfc_option
.max_subrecord_length
= value
;
1106 case OPT_frecursive
:
1107 gfc_option
.flag_recursive
= value
;
1110 case OPT_falign_commons
:
1111 gfc_option
.flag_align_commons
= value
;
1114 case OPT_faggressive_function_elimination
:
1115 gfc_option
.flag_aggressive_function_elimination
= value
;
1118 case OPT_ffrontend_optimize
:
1119 gfc_option
.flag_frontend_optimize
= value
;
1122 case OPT_fprotect_parens
:
1123 gfc_option
.flag_protect_parens
= value
;
1126 case OPT_frealloc_lhs
:
1127 gfc_option
.flag_realloc_lhs
= value
;
1131 gfc_handle_runtime_check_option (arg
);
1135 gfc_handle_coarray_option (arg
);
1139 Fortran_handle_option_auto (&global_options
, &global_options_set
,
1141 gfc_option_lang_mask (), kind
,
1142 loc
, handlers
, global_dc
);
1147 /* Return a string with the options passed to the compiler; used for
1148 Fortran's compiler_options() intrinsic. */
1151 gfc_get_option_string (void)
1157 /* Allocate and return a one-character string with '\0'. */
1158 if (!save_decoded_options_count
)
1159 return XCNEWVEC (char, 1);
1161 /* Determine required string length. */
1164 for (j
= 1; j
< save_decoded_options_count
; j
++)
1166 switch (save_decoded_options
[j
].opt_index
)
1175 case OPT_fintrinsic_modules_path
:
1176 case OPT_fintrinsic_modules_path_
:
1180 /* Ignore file names. */
1181 if (save_decoded_options
[j
].orig_option_with_args_text
[0] == '-')
1183 + strlen (save_decoded_options
[j
].orig_option_with_args_text
);
1187 result
= XCNEWVEC (char, len
);
1190 for (j
= 1; j
< save_decoded_options_count
; j
++)
1192 switch (save_decoded_options
[j
].opt_index
)
1201 case OPT_fintrinsic_modules_path
:
1202 case OPT_fintrinsic_modules_path_
:
1207 /* Use "-cpp" rather than "-cpp=<temporary file>". */
1212 /* Ignore file names. */
1213 if (save_decoded_options
[j
].orig_option_with_args_text
[0] != '-')
1216 len
= strlen (save_decoded_options
[j
].orig_option_with_args_text
);
1219 memcpy (&result
[pos
], save_decoded_options
[j
].orig_option_with_args_text
, len
);
1221 result
[pos
++] = ' ';
1224 result
[--pos
] = '\0';