diff options
author | Fritz Reese <fritzoreese@gmail.com> | 2018-12-03 15:42:51 +0000 |
---|---|---|
committer | Fritz Reese <foreese@gcc.gnu.org> | 2018-12-03 15:42:51 +0000 |
commit | 7ed760c79399c2d0a3406f28c6fd85f95bf6097c (patch) | |
tree | 65e401cb045d5ba626f4aeea61a1eb510b9ec1cc /gcc/fortran/options.c | |
parent | 509f987074e247f84afbd37af0d13a9179870d74 (diff) | |
download | gcc-7ed760c79399c2d0a3406f28c6fd85f95bf6097c.zip gcc-7ed760c79399c2d0a3406f28c6fd85f95bf6097c.tar.gz gcc-7ed760c79399c2d0a3406f28c6fd85f95bf6097c.tar.bz2 |
re PR fortran/87919 (Incorrect fortran handling of -fno-* options)
2018-12-03 Fritz Reese <fritzoreese@gmail.com>
Mark Eggleston <mark.eggleston@codethink.co.uk>
PR fortran/87919
gcc/fortran/ChangeLog:
PR fortran/87919
* options.c (SET_FLAG, SET_BITFLAG, SET_BITFLAG2): New macros.
(set_dec_flags): Set/unset DEC and std flags according to value.
(set_init_local_zero): New helper for -finit-local-zero flag group.
(gfc_init_options): Fix disabling of init flags, array temporaries
check, and dec flags when value is zero (from -fno-*).
gcc/testsuite/ChangeLog:
PR fortran/87919
* gfortran.dg/array_temporaries_5.f90: New test.
* gfortran.dg/dec_bitwise_ops_3.f90: Ditto.
* gfortran.dg/dec_d_lines_3.f: Ditto.
* gfortran.dg/dec_exp_4.f90: Ditto.
* gfortran.dg/dec_exp_5.f90: Ditto.
* gfortran.dg/dec_io_7.f90: Ditto.
* gfortran.dg/dec_structure_24.f90: Ditto.
* gfortran.dg/dec_structure_25.f90: Ditto.
* gfortran.dg/dec_structure_26.f90: Ditto.
* gfortran.dg/dec_structure_27.f90: Ditto.
* gfortran.dg/dec_type_print_3.f90: Ditto.
* gfortran.dg/init_flag_20.f90: Ditto.
Co-Authored-By: Mark Eggleston <mark.eggleston@codethink.co.uk>
From-SVN: r266745
Diffstat (limited to 'gcc/fortran/options.c')
-rw-r--r-- | gcc/fortran/options.c | 65 |
1 files changed, 52 insertions, 13 deletions
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index e59ba31..b35bed3 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -32,6 +32,20 @@ along with GCC; see the file COPYING3. If not see 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 @@ -47,30 +61,55 @@ set_default_std_flags (void) 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) { + /* 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); +} + +/* 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) { - /* Allow legacy code without warnings. */ gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL - | GFC_STD_GNU | GFC_STD_LEGACY; + | 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; - flag_dec_include |= value; } +/* 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. */ |