1 /* Parse and display command line options.
2 Copyright (C) 2000-2013 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
->x_flag_associative_math
= -1;
72 /* Get ready for options handling. Keep in sync with
73 libgfortran/runtime/compile_options.c (init_compile_options). */
76 gfc_init_options (unsigned int decoded_options_count
,
77 struct cl_decoded_option
*decoded_options
)
79 gfc_source_file
= NULL
;
80 gfc_option
.module_dir
= NULL
;
81 gfc_option
.source_form
= FORM_UNKNOWN
;
82 gfc_option
.fixed_line_length
= 72;
83 gfc_option
.free_line_length
= 132;
84 gfc_option
.max_continue_fixed
= 255;
85 gfc_option
.max_continue_free
= 255;
86 gfc_option
.max_identifier_length
= GFC_MAX_SYMBOL_LEN
;
87 gfc_option
.max_subrecord_length
= 0;
88 gfc_option
.flag_max_array_constructor
= 65535;
89 gfc_option
.convert
= GFC_CONVERT_NATIVE
;
90 gfc_option
.record_marker
= 0;
91 gfc_option
.dump_fortran_original
= 0;
92 gfc_option
.dump_fortran_optimized
= 0;
94 gfc_option
.warn_aliasing
= 0;
95 gfc_option
.warn_ampersand
= 0;
96 gfc_option
.warn_character_truncation
= 0;
97 gfc_option
.warn_array_temp
= 0;
98 gfc_option
.warn_c_binding_type
= 0;
99 gfc_option
.gfc_warn_conversion
= 0;
100 gfc_option
.warn_conversion_extra
= 0;
101 gfc_option
.warn_function_elimination
= 0;
102 gfc_option
.warn_implicit_interface
= 0;
103 gfc_option
.warn_line_truncation
= 0;
104 gfc_option
.warn_surprising
= 0;
105 gfc_option
.warn_tabs
= 1;
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_realloc_lhs
= 0;
113 gfc_option
.warn_realloc_lhs_all
= 0;
114 gfc_option
.warn_compare_reals
= 0;
115 gfc_option
.warn_target_lifetime
= 0;
116 gfc_option
.max_errors
= 25;
118 gfc_option
.flag_all_intrinsics
= 0;
119 gfc_option
.flag_default_double
= 0;
120 gfc_option
.flag_default_integer
= 0;
121 gfc_option
.flag_default_real
= 0;
122 gfc_option
.flag_integer4_kind
= 0;
123 gfc_option
.flag_real4_kind
= 0;
124 gfc_option
.flag_real8_kind
= 0;
125 gfc_option
.flag_dollar_ok
= 0;
126 gfc_option
.flag_underscoring
= 1;
127 gfc_option
.flag_f2c
= 0;
128 gfc_option
.flag_second_underscore
= -1;
129 gfc_option
.flag_implicit_none
= 0;
131 /* Default value of flag_max_stack_var_size is set in gfc_post_options. */
132 gfc_option
.flag_max_stack_var_size
= -2;
133 gfc_option
.flag_stack_arrays
= -1;
135 gfc_option
.flag_range_check
= 1;
136 gfc_option
.flag_pack_derived
= 0;
137 gfc_option
.flag_repack_arrays
= 0;
138 gfc_option
.flag_preprocessed
= 0;
139 gfc_option
.flag_automatic
= 1;
140 gfc_option
.flag_backslash
= 0;
141 gfc_option
.flag_module_private
= 0;
142 gfc_option
.flag_backtrace
= 1;
143 gfc_option
.flag_allow_leading_underscore
= 0;
144 gfc_option
.flag_external_blas
= 0;
145 gfc_option
.blas_matmul_limit
= 30;
146 gfc_option
.flag_cray_pointer
= 0;
147 gfc_option
.flag_d_lines
= -1;
148 gfc_option
.gfc_flag_openmp
= 0;
149 gfc_option
.flag_sign_zero
= 1;
150 gfc_option
.flag_recursive
= 0;
151 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_OFF
;
152 gfc_option
.flag_init_integer_value
= 0;
153 gfc_option
.flag_init_real
= GFC_INIT_REAL_OFF
;
154 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_OFF
;
155 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_OFF
;
156 gfc_option
.flag_init_character_value
= (char)0;
157 gfc_option
.flag_align_commons
= 1;
158 gfc_option
.flag_protect_parens
= -1;
159 gfc_option
.flag_realloc_lhs
= -1;
160 gfc_option
.flag_aggressive_function_elimination
= 0;
161 gfc_option
.flag_frontend_optimize
= -1;
164 /* All except GFC_FPE_INEXACT. */
165 gfc_option
.fpe_summary
= GFC_FPE_INVALID
| GFC_FPE_DENORMAL
166 | GFC_FPE_ZERO
| GFC_FPE_OVERFLOW
168 gfc_option
.rtcheck
= 0;
169 gfc_option
.coarray
= GFC_FCOARRAY_NONE
;
171 set_default_std_flags ();
173 /* Initialize cpp-related options. */
174 gfc_cpp_init_options (decoded_options_count
, decoded_options
);
178 /* Determine the source form from the filename extension. We assume
179 case insensitivity. */
181 static gfc_source_form
182 form_from_filename (const char *filename
)
186 const char *extension
;
187 gfc_source_form form
;
214 }; /* sentinel value */
216 gfc_source_form f_form
;
220 /* Find end of file name. Note, filename is either a NULL pointer or
221 a NUL terminated string. */
223 while (filename
[i
] != '\0')
226 /* Find last period. */
227 while (i
>= 0 && (filename
[i
] != '.'))
230 /* Did we see a file extension? */
232 return FORM_UNKNOWN
; /* Nope */
234 /* Get file extension and compare it to others. */
235 fileext
= &(filename
[i
]);
238 f_form
= FORM_UNKNOWN
;
242 if (strcasecmp (fileext
, exttype
[i
].extension
) == 0)
244 f_form
= exttype
[i
].form
;
248 while (exttype
[i
].form
!= FORM_UNKNOWN
);
254 /* Finalize commandline options. */
257 gfc_post_options (const char **pfilename
)
259 const char *filename
= *pfilename
, *canon_source_file
= NULL
;
263 /* Excess precision other than "fast" requires front-end
265 if (flag_excess_precision_cmdline
== EXCESS_PRECISION_STANDARD
266 && TARGET_FLT_EVAL_METHOD_NON_DEFAULT
)
267 sorry ("-fexcess-precision=standard for Fortran");
268 flag_excess_precision_cmdline
= EXCESS_PRECISION_FAST
;
270 /* Fortran allows associative math - but we cannot reassociate if
271 we want traps or signed zeros. Cf. also flag_protect_parens. */
272 if (flag_associative_math
== -1)
273 flag_associative_math
= (!flag_trapping_math
&& !flag_signed_zeros
);
275 if (gfc_option
.flag_protect_parens
== -1)
276 gfc_option
.flag_protect_parens
= !optimize_fast
;
278 if (gfc_option
.flag_stack_arrays
== -1)
279 gfc_option
.flag_stack_arrays
= optimize_fast
;
281 /* By default, disable (re)allocation during assignment for -std=f95,
282 and enable it for F2003/F2008/GNU/Legacy. */
283 if (gfc_option
.flag_realloc_lhs
== -1)
285 if (gfc_option
.allow_std
& GFC_STD_F2003
)
286 gfc_option
.flag_realloc_lhs
= 1;
288 gfc_option
.flag_realloc_lhs
= 0;
291 /* -fbounds-check is equivalent to -fcheck=bounds */
292 if (flag_bounds_check
)
293 gfc_option
.rtcheck
|= GFC_RTCHECK_BOUNDS
;
295 if (flag_compare_debug
)
296 gfc_option
.dump_fortran_original
= 0;
298 /* Make -fmax-errors visible to gfortran's diagnostic machinery. */
299 if (global_options_set
.x_flag_max_errors
)
300 gfc_option
.max_errors
= flag_max_errors
;
302 /* Verify the input file name. */
303 if (!filename
|| strcmp (filename
, "-") == 0)
308 if (gfc_option
.flag_preprocessed
)
310 /* For preprocessed files, if the first tokens are of the form # NUM.
311 handle the directives so we know the original file name. */
312 gfc_source_file
= gfc_read_orig_filename (filename
, &canon_source_file
);
313 if (gfc_source_file
== NULL
)
314 gfc_source_file
= filename
;
316 *pfilename
= gfc_source_file
;
319 gfc_source_file
= filename
;
321 if (canon_source_file
== NULL
)
322 canon_source_file
= gfc_source_file
;
324 /* Adds the path where the source file is to the list of include files. */
326 i
= strlen (canon_source_file
);
327 while (i
> 0 && !IS_DIR_SEPARATOR (canon_source_file
[i
]))
332 source_path
= (char *) alloca (i
+ 1);
333 memcpy (source_path
, canon_source_file
, i
);
335 gfc_add_include_path (source_path
, true, true, true);
338 gfc_add_include_path (".", true, true, true);
340 if (canon_source_file
!= gfc_source_file
)
341 free (CONST_CAST (char *, canon_source_file
));
343 /* Decide which form the file will be read in as. */
345 if (gfc_option
.source_form
!= FORM_UNKNOWN
)
346 gfc_current_form
= gfc_option
.source_form
;
349 gfc_current_form
= form_from_filename (filename
);
351 if (gfc_current_form
== FORM_UNKNOWN
)
353 gfc_current_form
= FORM_FREE
;
354 gfc_warning_now ("Reading file '%s' as free form",
355 (filename
[0] == '\0') ? "<stdin>" : filename
);
359 /* If the user specified -fd-lines-as-{code|comments} verify that we're
361 if (gfc_current_form
== FORM_FREE
)
363 if (gfc_option
.flag_d_lines
== 0)
364 gfc_warning_now ("'-fd-lines-as-comments' has no effect "
366 else if (gfc_option
.flag_d_lines
== 1)
367 gfc_warning_now ("'-fd-lines-as-code' has no effect in free form");
370 /* If -pedantic, warn about the use of GNU extensions. */
371 if (pedantic
&& (gfc_option
.allow_std
& GFC_STD_GNU
) != 0)
372 gfc_option
.warn_std
|= GFC_STD_GNU
;
373 /* -std=legacy -pedantic is effectively -std=gnu. */
374 if (pedantic
&& (gfc_option
.allow_std
& GFC_STD_LEGACY
) != 0)
375 gfc_option
.warn_std
|= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
| GFC_STD_LEGACY
;
377 /* If the user didn't explicitly specify -f(no)-second-underscore we
378 use it if we're trying to be compatible with f2c, and not
380 if (gfc_option
.flag_second_underscore
== -1)
381 gfc_option
.flag_second_underscore
= gfc_option
.flag_f2c
;
383 if (!gfc_option
.flag_automatic
&& gfc_option
.flag_max_stack_var_size
!= -2
384 && gfc_option
.flag_max_stack_var_size
!= 0)
385 gfc_warning_now ("Flag -fno-automatic overwrites -fmax-stack-var-size=%d",
386 gfc_option
.flag_max_stack_var_size
);
387 else if (!gfc_option
.flag_automatic
&& gfc_option
.flag_recursive
)
388 gfc_warning_now ("Flag -fno-automatic overwrites -frecursive");
389 else if (!gfc_option
.flag_automatic
&& gfc_option
.gfc_flag_openmp
)
390 gfc_warning_now ("Flag -fno-automatic overwrites -frecursive implied by "
392 else if (gfc_option
.flag_max_stack_var_size
!= -2
393 && gfc_option
.flag_recursive
)
394 gfc_warning_now ("Flag -frecursive overwrites -fmax-stack-var-size=%d",
395 gfc_option
.flag_max_stack_var_size
);
396 else if (gfc_option
.flag_max_stack_var_size
!= -2
397 && gfc_option
.gfc_flag_openmp
)
398 gfc_warning_now ("Flag -fmax-stack-var-size=%d overwrites -frecursive "
399 "implied by -fopenmp",
400 gfc_option
.flag_max_stack_var_size
);
402 /* Implement -frecursive as -fmax-stack-var-size=-1. */
403 if (gfc_option
.flag_recursive
)
404 gfc_option
.flag_max_stack_var_size
= -1;
406 /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
407 if (gfc_option
.flag_max_stack_var_size
== -2 && gfc_option
.gfc_flag_openmp
408 && gfc_option
.flag_automatic
)
410 gfc_option
.flag_recursive
= 1;
411 gfc_option
.flag_max_stack_var_size
= -1;
415 if (gfc_option
.flag_max_stack_var_size
== -2)
416 gfc_option
.flag_max_stack_var_size
= 32768;
418 /* Implement -fno-automatic as -fmax-stack-var-size=0. */
419 if (!gfc_option
.flag_automatic
)
420 gfc_option
.flag_max_stack_var_size
= 0;
424 gfc_option
.warn_ampersand
= 1;
425 gfc_option
.warn_tabs
= 0;
428 /* Optimization implies front end optimization, unless the user
429 specified it directly. */
431 if (gfc_option
.flag_frontend_optimize
== -1)
432 gfc_option
.flag_frontend_optimize
= optimize
;
434 if (gfc_option
.warn_realloc_lhs_all
)
435 gfc_option
.warn_realloc_lhs
= 1;
437 gfc_cpp_post_options ();
439 /* FIXME: return gfc_cpp_preprocess_only ();
441 The return value of this function indicates whether the
442 backend needs to be initialized. On -E, we don't need
443 the backend. However, if we return 'true' here, an
444 ICE occurs. Initializing the backend doesn't hurt much,
445 hence, for now we can live with it as is. */
450 /* Set the options for -Wall. */
453 set_Wall (int setting
)
455 gfc_option
.warn_aliasing
= setting
;
456 gfc_option
.warn_ampersand
= setting
;
457 gfc_option
.warn_c_binding_type
= setting
;
458 gfc_option
.gfc_warn_conversion
= setting
;
459 gfc_option
.warn_line_truncation
= setting
;
460 gfc_option
.warn_surprising
= setting
;
461 gfc_option
.warn_tabs
= !setting
;
462 gfc_option
.warn_underflow
= setting
;
463 gfc_option
.warn_intrinsic_shadow
= setting
;
464 gfc_option
.warn_intrinsics_std
= setting
;
465 gfc_option
.warn_character_truncation
= setting
;
466 gfc_option
.warn_real_q_constant
= setting
;
467 gfc_option
.warn_unused_dummy_argument
= setting
;
468 gfc_option
.warn_target_lifetime
= setting
;
470 warn_return_type
= setting
;
471 warn_uninitialized
= setting
;
472 warn_maybe_uninitialized
= setting
;
475 /* Set the options for -Wextra. */
478 set_Wextra (int setting
)
480 gfc_option
.warn_compare_reals
= setting
;
484 gfc_handle_module_path_options (const char *arg
)
487 if (gfc_option
.module_dir
!= NULL
)
488 gfc_fatal_error ("gfortran: Only one -J option allowed");
490 gfc_option
.module_dir
= XCNEWVEC (char, strlen (arg
) + 2);
491 strcpy (gfc_option
.module_dir
, arg
);
493 gfc_add_include_path (gfc_option
.module_dir
, true, false, true);
495 strcat (gfc_option
.module_dir
, "/");
499 /* Handle options -ffpe-trap= and -ffpe-summary=. */
502 gfc_handle_fpe_option (const char *arg
, bool trap
)
504 int result
, pos
= 0, n
;
505 /* precision is a backwards compatibility alias for inexact. */
506 static const char * const exception
[] = { "invalid", "denormal", "zero",
507 "overflow", "underflow",
508 "inexact", "precision", NULL
};
509 static const int opt_exception
[] = { GFC_FPE_INVALID
, GFC_FPE_DENORMAL
,
510 GFC_FPE_ZERO
, GFC_FPE_OVERFLOW
,
511 GFC_FPE_UNDERFLOW
, GFC_FPE_INEXACT
,
515 /* As the default for -ffpe-summary= is nonzero, set it to 0. */
517 gfc_option
.fpe_summary
= 0;
524 while (arg
[pos
] && arg
[pos
] != ',')
528 if (!trap
&& strncmp ("none", arg
, pos
) == 0)
530 gfc_option
.fpe_summary
= 0;
535 else if (!trap
&& strncmp ("all", arg
, pos
) == 0)
537 gfc_option
.fpe_summary
= GFC_FPE_INVALID
| GFC_FPE_DENORMAL
538 | GFC_FPE_ZERO
| GFC_FPE_OVERFLOW
539 | GFC_FPE_UNDERFLOW
| GFC_FPE_INEXACT
;
545 for (n
= 0; exception
[n
] != NULL
; n
++)
547 if (exception
[n
] && strncmp (exception
[n
], arg
, pos
) == 0)
550 gfc_option
.fpe
|= opt_exception
[n
];
552 gfc_option
.fpe_summary
|= opt_exception
[n
];
559 if (!result
&& !trap
)
560 gfc_fatal_error ("Argument to -ffpe-trap is not valid: %s", arg
);
562 gfc_fatal_error ("Argument to -ffpe-summary is not valid: %s", arg
);
569 gfc_handle_coarray_option (const char *arg
)
571 if (strcmp (arg
, "none") == 0)
572 gfc_option
.coarray
= GFC_FCOARRAY_NONE
;
573 else if (strcmp (arg
, "single") == 0)
574 gfc_option
.coarray
= GFC_FCOARRAY_SINGLE
;
575 else if (strcmp (arg
, "lib") == 0)
576 gfc_option
.coarray
= GFC_FCOARRAY_LIB
;
578 gfc_fatal_error ("Argument to -fcoarray is not valid: %s", arg
);
583 gfc_handle_runtime_check_option (const char *arg
)
585 int result
, pos
= 0, n
;
586 static const char * const optname
[] = { "all", "bounds", "array-temps",
587 "recursion", "do", "pointer",
589 static const int optmask
[] = { GFC_RTCHECK_ALL
, GFC_RTCHECK_BOUNDS
,
590 GFC_RTCHECK_ARRAY_TEMPS
,
591 GFC_RTCHECK_RECURSION
, GFC_RTCHECK_DO
,
592 GFC_RTCHECK_POINTER
, GFC_RTCHECK_MEM
,
600 while (arg
[pos
] && arg
[pos
] != ',')
604 for (n
= 0; optname
[n
] != NULL
; n
++)
606 if (optname
[n
] && strncmp (optname
[n
], arg
, pos
) == 0)
608 gfc_option
.rtcheck
|= optmask
[n
];
616 gfc_fatal_error ("Argument to -fcheck is not valid: %s", arg
);
621 /* Handle command-line options. Returns 0 if unrecognized, 1 if
622 recognized and handled. */
625 gfc_handle_option (size_t scode
, const char *arg
, int value
,
626 int kind ATTRIBUTE_UNUSED
, location_t loc ATTRIBUTE_UNUSED
,
627 const struct cl_option_handlers
*handlers ATTRIBUTE_UNUSED
)
630 enum opt_code code
= (enum opt_code
) scode
;
632 if (gfc_cpp_handle_option (scode
, arg
, value
) == 1)
642 handle_generated_option (&global_options
, &global_options_set
,
643 OPT_Wunused
, NULL
, value
,
644 gfc_option_lang_mask (), kind
, loc
,
645 handlers
, global_dc
);
650 gfc_option
.warn_aliasing
= value
;
654 gfc_option
.warn_ampersand
= value
;
657 case OPT_Warray_temporaries
:
658 gfc_option
.warn_array_temp
= value
;
661 case OPT_Wc_binding_type
:
662 gfc_option
.warn_c_binding_type
= value
;
665 case OPT_Wcharacter_truncation
:
666 gfc_option
.warn_character_truncation
= value
;
669 case OPT_Wcompare_reals
:
670 gfc_option
.warn_compare_reals
= value
;
673 case OPT_Wconversion
:
674 gfc_option
.gfc_warn_conversion
= value
;
677 case OPT_Wconversion_extra
:
678 gfc_option
.warn_conversion_extra
= value
;
682 handle_generated_option (&global_options
, &global_options_set
,
683 OPT_Wunused_parameter
, NULL
, value
,
684 gfc_option_lang_mask (), kind
, loc
,
685 handlers
, global_dc
);
690 case OPT_Wfunction_elimination
:
691 gfc_option
.warn_function_elimination
= value
;
694 case OPT_Wimplicit_interface
:
695 gfc_option
.warn_implicit_interface
= value
;
698 case OPT_Wimplicit_procedure
:
699 gfc_option
.warn_implicit_procedure
= value
;
702 case OPT_Wline_truncation
:
703 gfc_option
.warn_line_truncation
= value
;
706 case OPT_Wrealloc_lhs
:
707 gfc_option
.warn_realloc_lhs
= value
;
710 case OPT_Wrealloc_lhs_all
:
711 gfc_option
.warn_realloc_lhs_all
= value
;
714 case OPT_Wreturn_type
:
715 warn_return_type
= value
;
718 case OPT_Wsurprising
:
719 gfc_option
.warn_surprising
= value
;
723 gfc_option
.warn_tabs
= value
;
726 case OPT_Wtarget_lifetime
:
727 gfc_option
.warn_target_lifetime
= value
;
731 gfc_option
.warn_underflow
= value
;
734 case OPT_Wintrinsic_shadow
:
735 gfc_option
.warn_intrinsic_shadow
= value
;
738 case OPT_Walign_commons
:
739 gfc_option
.warn_align_commons
= value
;
742 case OPT_Wreal_q_constant
:
743 gfc_option
.warn_real_q_constant
= value
;
746 case OPT_Wunused_dummy_argument
:
747 gfc_option
.warn_unused_dummy_argument
= value
;
750 case OPT_fall_intrinsics
:
751 gfc_option
.flag_all_intrinsics
= 1;
755 gfc_option
.flag_automatic
= value
;
758 case OPT_fallow_leading_underscore
:
759 gfc_option
.flag_allow_leading_underscore
= value
;
763 gfc_option
.flag_backslash
= value
;
767 gfc_option
.flag_backtrace
= value
;
770 case OPT_fcheck_array_temporaries
:
771 gfc_option
.rtcheck
|= GFC_RTCHECK_ARRAY_TEMPS
;
774 case OPT_fcray_pointer
:
775 gfc_option
.flag_cray_pointer
= value
;
779 gfc_option
.flag_f2c
= value
;
783 gfc_option
.flag_dollar_ok
= value
;
786 case OPT_fexternal_blas
:
787 gfc_option
.flag_external_blas
= value
;
790 case OPT_fblas_matmul_limit_
:
791 gfc_option
.blas_matmul_limit
= value
;
794 case OPT_fd_lines_as_code
:
795 gfc_option
.flag_d_lines
= 1;
798 case OPT_fd_lines_as_comments
:
799 gfc_option
.flag_d_lines
= 0;
802 case OPT_fdump_fortran_original
:
803 case OPT_fdump_parse_tree
:
804 gfc_option
.dump_fortran_original
= value
;
807 case OPT_fdump_fortran_optimized
:
808 gfc_option
.dump_fortran_optimized
= value
;
811 case OPT_ffixed_form
:
812 gfc_option
.source_form
= FORM_FIXED
;
815 case OPT_ffixed_line_length_none
:
816 gfc_option
.fixed_line_length
= 0;
819 case OPT_ffixed_line_length_
:
820 if (value
!= 0 && value
< 7)
821 gfc_fatal_error ("Fixed line length must be at least seven.");
822 gfc_option
.fixed_line_length
= value
;
826 gfc_option
.source_form
= FORM_FREE
;
830 gfc_option
.gfc_flag_openmp
= value
;
833 case OPT_ffree_line_length_none
:
834 gfc_option
.free_line_length
= 0;
837 case OPT_ffree_line_length_
:
838 if (value
!= 0 && value
< 4)
839 gfc_fatal_error ("Free line length must be at least three.");
840 gfc_option
.free_line_length
= value
;
843 case OPT_funderscoring
:
844 gfc_option
.flag_underscoring
= value
;
847 case OPT_fsecond_underscore
:
848 gfc_option
.flag_second_underscore
= value
;
851 case OPT_static_libgfortran
:
852 #ifndef HAVE_LD_STATIC_DYNAMIC
853 gfc_fatal_error ("-static-libgfortran is not supported in this "
858 case OPT_fimplicit_none
:
859 gfc_option
.flag_implicit_none
= value
;
862 case OPT_fintrinsic_modules_path
:
863 case OPT_fintrinsic_modules_path_
:
865 /* This is needed because omp_lib.h is in a directory together
866 with intrinsic modules. Do no warn because during testing
867 without an installed compiler, we would get lots of bogus
868 warnings for a missing include directory. */
869 gfc_add_include_path (arg
, false, false, false);
871 gfc_add_intrinsic_modules_path (arg
);
874 case OPT_fmax_array_constructor_
:
875 gfc_option
.flag_max_array_constructor
= value
> 65535 ? value
: 65535;
878 case OPT_fmax_stack_var_size_
:
879 gfc_option
.flag_max_stack_var_size
= value
;
882 case OPT_fstack_arrays
:
883 gfc_option
.flag_stack_arrays
= value
;
886 case OPT_fmodule_private
:
887 gfc_option
.flag_module_private
= value
;
890 case OPT_frange_check
:
891 gfc_option
.flag_range_check
= value
;
894 case OPT_fpack_derived
:
895 gfc_option
.flag_pack_derived
= value
;
898 case OPT_frepack_arrays
:
899 gfc_option
.flag_repack_arrays
= value
;
902 case OPT_fpreprocessed
:
903 gfc_option
.flag_preprocessed
= value
;
906 case OPT_fmax_identifier_length_
:
907 if (value
> GFC_MAX_SYMBOL_LEN
)
908 gfc_fatal_error ("Maximum supported identifier length is %d",
910 gfc_option
.max_identifier_length
= value
;
913 case OPT_fdefault_integer_8
:
914 gfc_option
.flag_default_integer
= value
;
917 case OPT_fdefault_real_8
:
918 gfc_option
.flag_default_real
= value
;
921 case OPT_fdefault_double_8
:
922 gfc_option
.flag_default_double
= value
;
925 case OPT_finteger_4_integer_8
:
926 gfc_option
.flag_integer4_kind
= 8;
929 case OPT_freal_4_real_8
:
930 gfc_option
.flag_real4_kind
= 8;
933 case OPT_freal_4_real_10
:
934 gfc_option
.flag_real4_kind
= 10;
937 case OPT_freal_4_real_16
:
938 gfc_option
.flag_real4_kind
= 16;
941 case OPT_freal_8_real_4
:
942 gfc_option
.flag_real8_kind
= 4;
945 case OPT_freal_8_real_10
:
946 gfc_option
.flag_real8_kind
= 10;
949 case OPT_freal_8_real_16
:
950 gfc_option
.flag_real8_kind
= 16;
953 case OPT_finit_local_zero
:
954 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_ON
;
955 gfc_option
.flag_init_integer_value
= 0;
956 gfc_option
.flag_init_real
= GFC_INIT_REAL_ZERO
;
957 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_FALSE
;
958 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_ON
;
959 gfc_option
.flag_init_character_value
= (char)0;
962 case OPT_finit_logical_
:
963 if (!strcasecmp (arg
, "false"))
964 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_FALSE
;
965 else if (!strcasecmp (arg
, "true"))
966 gfc_option
.flag_init_logical
= GFC_INIT_LOGICAL_TRUE
;
968 gfc_fatal_error ("Unrecognized option to -finit-logical: %s",
972 case OPT_finit_real_
:
973 if (!strcasecmp (arg
, "zero"))
974 gfc_option
.flag_init_real
= GFC_INIT_REAL_ZERO
;
975 else if (!strcasecmp (arg
, "nan"))
976 gfc_option
.flag_init_real
= GFC_INIT_REAL_NAN
;
977 else if (!strcasecmp (arg
, "snan"))
978 gfc_option
.flag_init_real
= GFC_INIT_REAL_SNAN
;
979 else if (!strcasecmp (arg
, "inf"))
980 gfc_option
.flag_init_real
= GFC_INIT_REAL_INF
;
981 else if (!strcasecmp (arg
, "-inf"))
982 gfc_option
.flag_init_real
= GFC_INIT_REAL_NEG_INF
;
984 gfc_fatal_error ("Unrecognized option to -finit-real: %s",
988 case OPT_finit_integer_
:
989 gfc_option
.flag_init_integer
= GFC_INIT_INTEGER_ON
;
990 gfc_option
.flag_init_integer_value
= atoi (arg
);
993 case OPT_finit_character_
:
994 if (value
>= 0 && value
<= 127)
996 gfc_option
.flag_init_character
= GFC_INIT_CHARACTER_ON
;
997 gfc_option
.flag_init_character_value
= (char)value
;
1000 gfc_fatal_error ("The value of n in -finit-character=n must be "
1001 "between 0 and 127");
1005 gfc_add_include_path (arg
, true, false, true);
1009 gfc_handle_module_path_options (arg
);
1012 case OPT_fsign_zero
:
1013 gfc_option
.flag_sign_zero
= value
;
1016 case OPT_ffpe_trap_
:
1017 gfc_handle_fpe_option (arg
, true);
1020 case OPT_ffpe_summary_
:
1021 gfc_handle_fpe_option (arg
, false);
1025 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F95
| GFC_STD_F77
1026 | GFC_STD_F2008_OBS
;
1027 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
1028 gfc_option
.max_continue_fixed
= 19;
1029 gfc_option
.max_continue_free
= 39;
1030 gfc_option
.max_identifier_length
= 31;
1031 gfc_option
.warn_ampersand
= 1;
1032 gfc_option
.warn_tabs
= 0;
1036 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F77
1037 | GFC_STD_F2003
| GFC_STD_F95
| GFC_STD_F2008_OBS
;
1038 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
1039 gfc_option
.max_identifier_length
= 63;
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
| GFC_STD_F2008_OBS
;
1047 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2008_OBS
;
1048 gfc_option
.max_identifier_length
= 63;
1049 gfc_option
.warn_ampersand
= 1;
1050 gfc_option
.warn_tabs
= 0;
1053 case OPT_std_f2008ts
:
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
1057 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2008_OBS
;
1058 gfc_option
.max_identifier_length
= 63;
1059 gfc_option
.warn_ampersand
= 1;
1060 gfc_option
.warn_tabs
= 0;
1064 set_default_std_flags ();
1067 case OPT_std_legacy
:
1068 set_default_std_flags ();
1069 gfc_option
.warn_std
= 0;
1072 case OPT_Wintrinsics_std
:
1073 gfc_option
.warn_intrinsics_std
= value
;
1076 case OPT_fshort_enums
:
1077 /* Handled in language-independent code. */
1080 case OPT_fconvert_little_endian
:
1081 gfc_option
.convert
= GFC_CONVERT_LITTLE
;
1084 case OPT_fconvert_big_endian
:
1085 gfc_option
.convert
= GFC_CONVERT_BIG
;
1088 case OPT_fconvert_native
:
1089 gfc_option
.convert
= GFC_CONVERT_NATIVE
;
1092 case OPT_fconvert_swap
:
1093 gfc_option
.convert
= GFC_CONVERT_SWAP
;
1096 case OPT_frecord_marker_4
:
1097 gfc_option
.record_marker
= 4;
1100 case OPT_frecord_marker_8
:
1101 gfc_option
.record_marker
= 8;
1104 case OPT_fmax_subrecord_length_
:
1105 if (value
> MAX_SUBRECORD_LENGTH
)
1106 gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
1107 MAX_SUBRECORD_LENGTH
);
1109 gfc_option
.max_subrecord_length
= value
;
1112 case OPT_frecursive
:
1113 gfc_option
.flag_recursive
= value
;
1116 case OPT_falign_commons
:
1117 gfc_option
.flag_align_commons
= value
;
1120 case OPT_faggressive_function_elimination
:
1121 gfc_option
.flag_aggressive_function_elimination
= value
;
1124 case OPT_ffrontend_optimize
:
1125 gfc_option
.flag_frontend_optimize
= value
;
1128 case OPT_fprotect_parens
:
1129 gfc_option
.flag_protect_parens
= value
;
1132 case OPT_frealloc_lhs
:
1133 gfc_option
.flag_realloc_lhs
= value
;
1137 gfc_handle_runtime_check_option (arg
);
1141 gfc_handle_coarray_option (arg
);
1145 Fortran_handle_option_auto (&global_options
, &global_options_set
,
1147 gfc_option_lang_mask (), kind
,
1148 loc
, handlers
, global_dc
);
1153 /* Return a string with the options passed to the compiler; used for
1154 Fortran's compiler_options() intrinsic. */
1157 gfc_get_option_string (void)
1163 /* Determine required string length. */
1166 for (j
= 1; j
< save_decoded_options_count
; j
++)
1168 switch (save_decoded_options
[j
].opt_index
)
1177 case OPT_fintrinsic_modules_path
:
1178 case OPT_fintrinsic_modules_path_
:
1182 /* Ignore file names. */
1183 if (save_decoded_options
[j
].orig_option_with_args_text
[0] == '-')
1185 + strlen (save_decoded_options
[j
].orig_option_with_args_text
);
1189 result
= XCNEWVEC (char, len
);
1192 for (j
= 1; j
< save_decoded_options_count
; j
++)
1194 switch (save_decoded_options
[j
].opt_index
)
1203 case OPT_fintrinsic_modules_path
:
1204 case OPT_fintrinsic_modules_path_
:
1209 /* Use "-cpp" rather than "-cpp=<temporary file>". */
1214 /* Ignore file names. */
1215 if (save_decoded_options
[j
].orig_option_with_args_text
[0] != '-')
1218 len
= strlen (save_decoded_options
[j
].orig_option_with_args_text
);
1221 memcpy (&result
[pos
], save_decoded_options
[j
].orig_option_with_args_text
, len
);
1223 result
[pos
++] = ' ';
1226 result
[--pos
] = '\0';