Mercurial > hg > CbC > CbC_gcc
comparison gcc/fortran/options.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* Parse and display command line options. | 1 /* Parse and display command line options. |
2 Copyright (C) 2000-2018 Free Software Foundation, Inc. | 2 Copyright (C) 2000-2020 Free Software Foundation, Inc. |
3 Contributed by Andy Vaught | 3 Contributed by Andy Vaught |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
30 #include "cpp.h" | 30 #include "cpp.h" |
31 #include "langhooks.h" | 31 #include "langhooks.h" |
32 | 32 |
33 gfc_option_t gfc_option; | 33 gfc_option_t gfc_option; |
34 | 34 |
35 #define SET_FLAG(flag, condition, on_value, off_value) \ | |
36 do \ | |
37 { \ | |
38 if (condition) \ | |
39 flag = (on_value); \ | |
40 else \ | |
41 flag = (off_value); \ | |
42 } while (0) | |
43 | |
44 #define SET_BITFLAG2(m) m | |
45 | |
46 #define SET_BITFLAG(flag, condition, value) \ | |
47 SET_BITFLAG2 (SET_FLAG (flag, condition, (flag | (value)), (flag & ~(value)))) | |
48 | |
35 | 49 |
36 /* Set flags that control warnings and errors for different | 50 /* Set flags that control warnings and errors for different |
37 Fortran standards to their default values. Keep in sync with | 51 Fortran standards to their default values. Keep in sync with |
38 libgfortran/runtime/compile_options.c (init_compile_options). */ | 52 libgfortran/runtime/compile_options.c (init_compile_options). */ |
39 | 53 |
45 | GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY | 59 | GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY |
46 | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS; | 60 | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS; |
47 gfc_option.warn_std = GFC_STD_F2018_DEL | GFC_STD_F95_DEL | GFC_STD_LEGACY; | 61 gfc_option.warn_std = GFC_STD_F2018_DEL | GFC_STD_F95_DEL | GFC_STD_LEGACY; |
48 } | 62 } |
49 | 63 |
50 | 64 /* Set (or unset) the DEC extension flags. */ |
51 /* Set all the DEC extension flags. */ | |
52 | 65 |
53 static void | 66 static void |
54 set_dec_flags (int value) | 67 set_dec_flags (int value) |
55 { | 68 { |
69 /* Set (or unset) other DEC compatibility extensions. */ | |
70 SET_BITFLAG (flag_dollar_ok, value, value); | |
71 SET_BITFLAG (flag_cray_pointer, value, value); | |
72 SET_BITFLAG (flag_dec_structure, value, value); | |
73 SET_BITFLAG (flag_dec_intrinsic_ints, value, value); | |
74 SET_BITFLAG (flag_dec_static, value, value); | |
75 SET_BITFLAG (flag_dec_math, value, value); | |
76 SET_BITFLAG (flag_dec_include, value, value); | |
77 SET_BITFLAG (flag_dec_format_defaults, value, value); | |
78 SET_BITFLAG (flag_dec_blank_format_item, value, value); | |
79 SET_BITFLAG (flag_dec_char_conversions, value, value); | |
80 } | |
81 | |
82 /* Finalize DEC flags. */ | |
83 | |
84 static void | |
85 post_dec_flags (int value) | |
86 { | |
87 /* Don't warn for legacy code if -fdec is given; however, setting -fno-dec | |
88 does not force these warnings. We make one final determination on this | |
89 at the end because -std= is always set first; thus, we can avoid | |
90 clobbering the user's desired standard settings in gfc_handle_option | |
91 e.g. when -fdec and -fno-dec are both given. */ | |
56 if (value) | 92 if (value) |
57 { | 93 { |
58 /* Allow legacy code without warnings. */ | |
59 gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | 94 gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL |
60 | GFC_STD_GNU | GFC_STD_LEGACY; | 95 | GFC_STD_GNU | GFC_STD_LEGACY; |
61 gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL); | 96 gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL); |
62 } | 97 } |
63 | 98 } |
64 /* Set other DEC compatibility extensions. */ | 99 |
65 flag_dollar_ok |= value; | 100 /* Enable (or disable) -finit-local-zero. */ |
66 flag_cray_pointer |= value; | 101 |
67 flag_dec_structure |= value; | 102 static void |
68 flag_dec_intrinsic_ints |= value; | 103 set_init_local_zero (int value) |
69 flag_dec_static |= value; | 104 { |
70 flag_dec_math |= value; | 105 gfc_option.flag_init_integer_value = 0; |
71 } | 106 gfc_option.flag_init_character_value = (char)0; |
72 | 107 |
108 SET_FLAG (gfc_option.flag_init_integer, value, GFC_INIT_INTEGER_ON, | |
109 GFC_INIT_INTEGER_OFF); | |
110 SET_FLAG (gfc_option.flag_init_logical, value, GFC_INIT_LOGICAL_FALSE, | |
111 GFC_INIT_LOGICAL_OFF); | |
112 SET_FLAG (gfc_option.flag_init_character, value, GFC_INIT_CHARACTER_ON, | |
113 GFC_INIT_CHARACTER_OFF); | |
114 SET_FLAG (flag_init_real, value, GFC_INIT_REAL_ZERO, GFC_INIT_REAL_OFF); | |
115 } | |
73 | 116 |
74 /* Return language mask for Fortran options. */ | 117 /* Return language mask for Fortran options. */ |
75 | 118 |
76 unsigned int | 119 unsigned int |
77 gfc_option_lang_mask (void) | 120 gfc_option_lang_mask (void) |
105 gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN; | 148 gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN; |
106 gfc_option.max_errors = 25; | 149 gfc_option.max_errors = 25; |
107 | 150 |
108 gfc_option.flag_preprocessed = 0; | 151 gfc_option.flag_preprocessed = 0; |
109 gfc_option.flag_d_lines = -1; | 152 gfc_option.flag_d_lines = -1; |
110 gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF; | 153 set_init_local_zero (0); |
111 gfc_option.flag_init_integer_value = 0; | |
112 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_OFF; | |
113 gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF; | |
114 gfc_option.flag_init_character_value = (char)0; | |
115 | 154 |
116 gfc_option.fpe = 0; | 155 gfc_option.fpe = 0; |
117 /* All except GFC_FPE_INEXACT. */ | 156 /* All except GFC_FPE_INEXACT. */ |
118 gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL | 157 gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL |
119 | GFC_FPE_ZERO | GFC_FPE_OVERFLOW | 158 | GFC_FPE_ZERO | GFC_FPE_OVERFLOW |
121 gfc_option.rtcheck = 0; | 160 gfc_option.rtcheck = 0; |
122 | 161 |
123 /* ??? Wmissing-include-dirs is disabled by default in C/C++ but | 162 /* ??? Wmissing-include-dirs is disabled by default in C/C++ but |
124 enabled by default in Fortran. Ideally, we should express this | 163 enabled by default in Fortran. Ideally, we should express this |
125 in .opt, but that is not supported yet. */ | 164 in .opt, but that is not supported yet. */ |
126 if (!global_options_set.x_cpp_warn_missing_include_dirs) | 165 SET_OPTION_IF_UNSET (&global_options, &global_options_set, |
127 global_options.x_cpp_warn_missing_include_dirs = 1; | 166 cpp_warn_missing_include_dirs, 1); |
128 | 167 |
129 set_dec_flags (0); | 168 set_dec_flags (0); |
130 | 169 |
131 set_default_std_flags (); | 170 set_default_std_flags (); |
132 | 171 |
219 { | 258 { |
220 const char *filename = *pfilename, *canon_source_file = NULL; | 259 const char *filename = *pfilename, *canon_source_file = NULL; |
221 char *source_path; | 260 char *source_path; |
222 int i; | 261 int i; |
223 | 262 |
263 /* Finalize DEC flags. */ | |
264 post_dec_flags (flag_dec); | |
265 | |
224 /* Excess precision other than "fast" requires front-end | 266 /* Excess precision other than "fast" requires front-end |
225 support. */ | 267 support. */ |
226 if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD) | 268 if (flag_excess_precision == EXCESS_PRECISION_STANDARD) |
227 sorry ("-fexcess-precision=standard for Fortran"); | 269 sorry ("%<-fexcess-precision=standard%> for Fortran"); |
228 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST; | 270 flag_excess_precision = EXCESS_PRECISION_FAST; |
229 | 271 |
230 /* Fortran allows associative math - but we cannot reassociate if | 272 /* Fortran allows associative math - but we cannot reassociate if |
231 we want traps or signed zeros. Cf. also flag_protect_parens. */ | 273 we want traps or signed zeros. Cf. also flag_protect_parens. */ |
232 if (flag_associative_math == -1) | 274 if (flag_associative_math == -1) |
233 flag_associative_math = (!flag_trapping_math && !flag_signed_zeros); | 275 flag_associative_math = (!flag_trapping_math && !flag_signed_zeros); |
366 if (!flag_automatic && flag_max_stack_var_size != -2 | 408 if (!flag_automatic && flag_max_stack_var_size != -2 |
367 && flag_max_stack_var_size != 0) | 409 && flag_max_stack_var_size != 0) |
368 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>", | 410 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>", |
369 flag_max_stack_var_size); | 411 flag_max_stack_var_size); |
370 else if (!flag_automatic && flag_recursive) | 412 else if (!flag_automatic && flag_recursive) |
371 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%>"); | 413 gfc_warning_now (OPT_Woverwrite_recursive, "Flag %<-fno-automatic%> " |
414 "overwrites %<-frecursive%>"); | |
372 else if (!flag_automatic && flag_openmp) | 415 else if (!flag_automatic && flag_openmp) |
373 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by " | 416 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by " |
374 "%<-fopenmp%>"); | 417 "%<-fopenmp%>"); |
375 else if (flag_max_stack_var_size != -2 && flag_recursive) | 418 else if (flag_max_stack_var_size != -2 && flag_recursive) |
376 gfc_warning_now (0, "Flag %<-frecursive%> overwrites %<-fmax-stack-var-size=%d%>", | 419 gfc_warning_now (0, "Flag %<-frecursive%> overwrites %<-fmax-stack-var-size=%d%>", |
394 if (flag_stack_arrays == -1) | 437 if (flag_stack_arrays == -1) |
395 flag_stack_arrays = 0; | 438 flag_stack_arrays = 0; |
396 | 439 |
397 /* Set default. */ | 440 /* Set default. */ |
398 if (flag_max_stack_var_size == -2) | 441 if (flag_max_stack_var_size == -2) |
399 flag_max_stack_var_size = 32768; | 442 flag_max_stack_var_size = 65536; |
400 | 443 |
401 /* Implement -fno-automatic as -fmax-stack-var-size=0. */ | 444 /* Implement -fno-automatic as -fmax-stack-var-size=0. */ |
402 if (!flag_automatic) | 445 if (!flag_automatic) |
403 flag_max_stack_var_size = 0; | 446 flag_max_stack_var_size = 0; |
404 | 447 |
421 | 464 |
422 /* Same for front end loop interchange. */ | 465 /* Same for front end loop interchange. */ |
423 | 466 |
424 if (flag_frontend_loop_interchange == -1) | 467 if (flag_frontend_loop_interchange == -1) |
425 flag_frontend_loop_interchange = optimize; | 468 flag_frontend_loop_interchange = optimize; |
469 | |
470 /* Do inline packing by default if optimizing, but not if | |
471 optimizing for size. */ | |
472 if (flag_inline_arg_packing == -1) | |
473 flag_inline_arg_packing = optimize && !optimize_size; | |
426 | 474 |
427 if (flag_max_array_constructor < 65535) | 475 if (flag_max_array_constructor < 65535) |
428 flag_max_array_constructor = 65535; | 476 flag_max_array_constructor = 65535; |
429 | 477 |
430 if (flag_fixed_line_length != 0 && flag_fixed_line_length < 7) | 478 if (flag_fixed_line_length != 0 && flag_fixed_line_length < 7) |
537 gfc_handle_runtime_check_option (const char *arg) | 585 gfc_handle_runtime_check_option (const char *arg) |
538 { | 586 { |
539 int result, pos = 0, n; | 587 int result, pos = 0, n; |
540 static const char * const optname[] = { "all", "bounds", "array-temps", | 588 static const char * const optname[] = { "all", "bounds", "array-temps", |
541 "recursion", "do", "pointer", | 589 "recursion", "do", "pointer", |
542 "mem", NULL }; | 590 "mem", "bits", NULL }; |
543 static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS, | 591 static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS, |
544 GFC_RTCHECK_ARRAY_TEMPS, | 592 GFC_RTCHECK_ARRAY_TEMPS, |
545 GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO, | 593 GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO, |
546 GFC_RTCHECK_POINTER, GFC_RTCHECK_MEM, | 594 GFC_RTCHECK_POINTER, GFC_RTCHECK_MEM, |
547 0 }; | 595 GFC_RTCHECK_BITS, 0 }; |
548 | 596 |
549 while (*arg) | 597 while (*arg) |
550 { | 598 { |
551 while (*arg == ',') | 599 while (*arg == ',') |
552 arg++; | 600 arg++; |
602 break; | 650 break; |
603 result = false; | 651 result = false; |
604 break; | 652 break; |
605 | 653 |
606 case OPT_fcheck_array_temporaries: | 654 case OPT_fcheck_array_temporaries: |
607 gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS; | 655 SET_BITFLAG (gfc_option.rtcheck, value, GFC_RTCHECK_ARRAY_TEMPS); |
608 break; | 656 break; |
609 | 657 |
610 case OPT_fd_lines_as_code: | 658 case OPT_fd_lines_as_code: |
611 gfc_option.flag_d_lines = 1; | 659 gfc_option.flag_d_lines = 1; |
612 break; | 660 break; |
652 GFC_MAX_SYMBOL_LEN); | 700 GFC_MAX_SYMBOL_LEN); |
653 gfc_option.max_identifier_length = value; | 701 gfc_option.max_identifier_length = value; |
654 break; | 702 break; |
655 | 703 |
656 case OPT_finit_local_zero: | 704 case OPT_finit_local_zero: |
657 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON; | 705 set_init_local_zero (value); |
658 gfc_option.flag_init_integer_value = 0; | |
659 flag_init_real = GFC_INIT_REAL_ZERO; | |
660 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE; | |
661 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON; | |
662 gfc_option.flag_init_character_value = (char)0; | |
663 break; | 706 break; |
664 | 707 |
665 case OPT_finit_logical_: | 708 case OPT_finit_logical_: |
666 if (!strcasecmp (arg, "false")) | 709 if (!strcasecmp (arg, "false")) |
667 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE; | 710 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE; |
672 arg); | 715 arg); |
673 break; | 716 break; |
674 | 717 |
675 case OPT_finit_integer_: | 718 case OPT_finit_integer_: |
676 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON; | 719 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON; |
677 gfc_option.flag_init_integer_value = atoi (arg); | 720 gfc_option.flag_init_integer_value = strtol (arg, NULL, 10); |
678 break; | 721 break; |
679 | 722 |
680 case OPT_finit_character_: | 723 case OPT_finit_character_: |
681 if (value >= 0 && value <= 127) | 724 if (value >= 0 && value <= 127) |
682 { | 725 { |
756 case OPT_fcheck_: | 799 case OPT_fcheck_: |
757 gfc_handle_runtime_check_option (arg); | 800 gfc_handle_runtime_check_option (arg); |
758 break; | 801 break; |
759 | 802 |
760 case OPT_fdec: | 803 case OPT_fdec: |
761 /* Enable all DEC extensions. */ | 804 /* Set (or unset) the DEC extension flags. */ |
762 set_dec_flags (1); | 805 set_dec_flags (value); |
763 break; | |
764 | |
765 case OPT_fdec_structure: | |
766 flag_dec_structure = 1; | |
767 break; | 806 break; |
768 } | 807 } |
769 | 808 |
770 Fortran_handle_option_auto (&global_options, &global_options_set, | 809 Fortran_handle_option_auto (&global_options, &global_options_set, |
771 scode, arg, value, | 810 scode, arg, value, |
853 } | 892 } |
854 | 893 |
855 result[--pos] = '\0'; | 894 result[--pos] = '\0'; |
856 return result; | 895 return result; |
857 } | 896 } |
897 | |
898 #undef SET_BITFLAG | |
899 #undef SET_BITFLAG2 | |
900 #undef SET_FLAG |