/* Parse and display command line options.
- Copyright (C) 2000-2017 Free Software Foundation, Inc.
+ Copyright (C) 2000-2020 Free Software Foundation, Inc.
Contributed by Andy Vaught
This file is part of GCC.
gfc_option_t gfc_option;
+#define SET_FLAG(flag, condition, on_value, off_value) \
+ do \
+ { \
+ if (condition) \
+ flag = (on_value); \
+ else \
+ flag = (off_value); \
+ } while (0)
+
+#define SET_BITFLAG2(m) m
+
+#define SET_BITFLAG(flag, condition, value) \
+ SET_BITFLAG2 (SET_FLAG (flag, condition, (flag | (value)), (flag & ~(value))))
+
/* Set flags that control warnings and errors for different
Fortran standards to their default values. Keep in sync with
{
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
- | GFC_STD_F2008_OBS | GFC_STD_F2008_TS | GFC_STD_GNU | GFC_STD_LEGACY;
- gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
+ | GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY
+ | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS;
+ gfc_option.warn_std = GFC_STD_F2018_DEL | GFC_STD_F95_DEL | GFC_STD_LEGACY;
}
-
-/* Set all the DEC extension flags. */
+/* Set (or unset) the DEC extension flags. */
static void
set_dec_flags (int value)
{
- /* Allow legacy code without warnings. */
- gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL
- | GFC_STD_GNU | GFC_STD_LEGACY;
- gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL);
-
-
- /* Set other DEC compatibility extensions. */
- flag_dollar_ok |= value;
- flag_cray_pointer |= value;
- flag_dec_structure |= value;
- flag_dec_intrinsic_ints |= value;
- flag_dec_static |= value;
- flag_dec_math |= value;
+ /* Set (or unset) other DEC compatibility extensions. */
+ SET_BITFLAG (flag_dollar_ok, value, value);
+ SET_BITFLAG (flag_cray_pointer, value, value);
+ SET_BITFLAG (flag_dec_structure, value, value);
+ SET_BITFLAG (flag_dec_intrinsic_ints, value, value);
+ SET_BITFLAG (flag_dec_static, value, value);
+ SET_BITFLAG (flag_dec_math, value, value);
+ SET_BITFLAG (flag_dec_include, value, value);
+ SET_BITFLAG (flag_dec_format_defaults, value, value);
+ SET_BITFLAG (flag_dec_blank_format_item, value, value);
+ SET_BITFLAG (flag_dec_char_conversions, value, value);
}
+/* Finalize DEC flags. */
+
+static void
+post_dec_flags (int value)
+{
+ /* Don't warn for legacy code if -fdec is given; however, setting -fno-dec
+ does not force these warnings. We make one final determination on this
+ at the end because -std= is always set first; thus, we can avoid
+ clobbering the user's desired standard settings in gfc_handle_option
+ e.g. when -fdec and -fno-dec are both given. */
+ if (value)
+ {
+ gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL
+ | GFC_STD_GNU | GFC_STD_LEGACY;
+ gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL);
+ }
+}
+
+/* Enable (or disable) -finit-local-zero. */
+
+static void
+set_init_local_zero (int value)
+{
+ gfc_option.flag_init_integer_value = 0;
+ gfc_option.flag_init_character_value = (char)0;
+
+ SET_FLAG (gfc_option.flag_init_integer, value, GFC_INIT_INTEGER_ON,
+ GFC_INIT_INTEGER_OFF);
+ SET_FLAG (gfc_option.flag_init_logical, value, GFC_INIT_LOGICAL_FALSE,
+ GFC_INIT_LOGICAL_OFF);
+ SET_FLAG (gfc_option.flag_init_character, value, GFC_INIT_CHARACTER_ON,
+ GFC_INIT_CHARACTER_OFF);
+ SET_FLAG (flag_init_real, value, GFC_INIT_REAL_ZERO, GFC_INIT_REAL_OFF);
+}
/* Return language mask for Fortran options. */
gfc_option.flag_preprocessed = 0;
gfc_option.flag_d_lines = -1;
- gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF;
- gfc_option.flag_init_integer_value = 0;
- gfc_option.flag_init_logical = GFC_INIT_LOGICAL_OFF;
- gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF;
- gfc_option.flag_init_character_value = (char)0;
+ set_init_local_zero (0);
gfc_option.fpe = 0;
/* All except GFC_FPE_INEXACT. */
/* ??? Wmissing-include-dirs is disabled by default in C/C++ but
enabled by default in Fortran. Ideally, we should express this
in .opt, but that is not supported yet. */
- if (!global_options_set.x_cpp_warn_missing_include_dirs)
- global_options.x_cpp_warn_missing_include_dirs = 1;
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+ cpp_warn_missing_include_dirs, 1);
set_dec_flags (0);
char *source_path;
int i;
+ /* Finalize DEC flags. */
+ post_dec_flags (flag_dec);
+
/* Excess precision other than "fast" requires front-end
support. */
- if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD)
- sorry ("-fexcess-precision=standard for Fortran");
- flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
+ if (flag_excess_precision == EXCESS_PRECISION_STANDARD)
+ sorry ("%<-fexcess-precision=standard%> for Fortran");
+ flag_excess_precision = EXCESS_PRECISION_FAST;
/* Fortran allows associative math - but we cannot reassociate if
we want traps or signed zeros. Cf. also flag_protect_parens. */
if (gfc_current_form == FORM_UNKNOWN)
{
gfc_current_form = FORM_FREE;
+ main_input_filename = filename;
gfc_warning_now (0, "Reading file %qs as free form",
(filename[0] == '\0') ? "<stdin>" : filename);
}
gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
flag_max_stack_var_size);
else if (!flag_automatic && flag_recursive)
- gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%>");
+ gfc_warning_now (OPT_Woverwrite_recursive, "Flag %<-fno-automatic%> "
+ "overwrites %<-frecursive%>");
else if (!flag_automatic && flag_openmp)
gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
"%<-fopenmp%>");
/* Set default. */
if (flag_max_stack_var_size == -2)
- flag_max_stack_var_size = 32768;
+ flag_max_stack_var_size = 65536;
/* Implement -fno-automatic as -fmax-stack-var-size=0. */
if (!flag_automatic)
specified it directly. */
if (flag_frontend_optimize == -1)
- flag_frontend_optimize = optimize;
+ flag_frontend_optimize = optimize && !optimize_debug;
+
+ /* Same for front end loop interchange. */
+
+ if (flag_frontend_loop_interchange == -1)
+ flag_frontend_loop_interchange = optimize;
+
+ /* Do inline packing by default if optimizing, but not if
+ optimizing for size. */
+ if (flag_inline_arg_packing == -1)
+ flag_inline_arg_packing = optimize && !optimize_size;
if (flag_max_array_constructor < 65535)
flag_max_array_constructor = 65535;
int result, pos = 0, n;
static const char * const optname[] = { "all", "bounds", "array-temps",
"recursion", "do", "pointer",
- "mem", NULL };
+ "mem", "bits", NULL };
static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS,
GFC_RTCHECK_ARRAY_TEMPS,
GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO,
GFC_RTCHECK_POINTER, GFC_RTCHECK_MEM,
- 0 };
+ GFC_RTCHECK_BITS, 0 };
while (*arg)
{
result = 1;
break;
}
- else if (optname[n] && pos > 3 && strncmp ("no-", arg, 3) == 0
+ else if (optname[n] && pos > 3 && gfc_str_startswith (arg, "no-")
&& strncmp (optname[n], arg+3, pos-3) == 0)
{
gfc_option.rtcheck &= ~optmask[n];
recognized and handled. */
bool
-gfc_handle_option (size_t scode, const char *arg, int value,
+gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED,
const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
{
break;
case OPT_fcheck_array_temporaries:
- gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS;
+ SET_BITFLAG (gfc_option.rtcheck, value, GFC_RTCHECK_ARRAY_TEMPS);
break;
case OPT_fd_lines_as_code:
break;
case OPT_finit_local_zero:
- gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
- gfc_option.flag_init_integer_value = 0;
- flag_init_real = GFC_INIT_REAL_ZERO;
- gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
- gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
- gfc_option.flag_init_character_value = (char)0;
+ set_init_local_zero (value);
break;
case OPT_finit_logical_:
case OPT_finit_integer_:
gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
- gfc_option.flag_init_integer_value = atoi (arg);
+ gfc_option.flag_init_integer_value = strtol (arg, NULL, 10);
break;
case OPT_finit_character_:
break;
case OPT_std_f95:
- gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77
- | GFC_STD_F2008_OBS;
+ gfc_option.allow_std = GFC_STD_OPT_F95;
gfc_option.warn_std = GFC_STD_F95_OBS;
gfc_option.max_continue_fixed = 19;
gfc_option.max_continue_free = 39;
break;
case OPT_std_f2003:
- gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
- | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008_OBS;
+ gfc_option.allow_std = GFC_STD_OPT_F03;
gfc_option.warn_std = GFC_STD_F95_OBS;
gfc_option.max_identifier_length = 63;
warn_ampersand = 1;
break;
case OPT_std_f2008:
- gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
- | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS;
+ gfc_option.allow_std = GFC_STD_OPT_F08;
gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
gfc_option.max_identifier_length = 63;
warn_ampersand = 1;
break;
case OPT_std_f2008ts:
- gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
- | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS
- | GFC_STD_F2008_TS;
- gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
+ case OPT_std_f2018:
+ gfc_option.allow_std = GFC_STD_OPT_F18;
+ gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS
+ | GFC_STD_F2018_OBS;
gfc_option.max_identifier_length = 63;
warn_ampersand = 1;
warn_tabs = 1;
break;
case OPT_fdec:
- /* Enable all DEC extensions. */
- set_dec_flags (1);
- break;
-
- case OPT_fdec_structure:
- flag_dec_structure = 1;
+ /* Set (or unset) the DEC extension flags. */
+ set_dec_flags (value);
break;
}
result[--pos] = '\0';
return result;
}
+
+#undef SET_BITFLAG
+#undef SET_BITFLAG2
+#undef SET_FLAG