Post by Jakub JelinekPost by Fritz ReesePost by Jakub JelinekWhat about the
/* 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);
that is done for value, shouldn't set_dec_flags remove those
flags again? Maybe not the allow_std ones, because those are set already by
default, perhaps just the warn_std flags?
Sure. I wasn't convinced about this and how it might interplay with
-std= so I left it alone, but I suppose it makes sense to unsuppress
the warnings when disabling -fdec.
Perhaps it might be better not to change the allow_std/warn_std flags
during the option parsing, instead set or clear say flag_dec and
only when option processing is being finalized (gfc_post_options)
check if flag_dec is set and set those. It would change behavior of
-fdec -std=f2018 and similar though. Not sure what users expect.
Actually, the gcc frontend appears to move -std= before the
language-specific options before f951 is even executed regardless of
its location compared to the -fdec flags. I don't know if this is a
bug or if it is by design -- the feeling I get is that the gcc
frontend processes it first since it is recognized before the flang
specific options. Therefore, greedily setting the standard options the
first time flag_dec appears means the standard information is lost and
I believe your suggestion is correct: the standard flags must be set
only once in gfc_post_options.
In fact the new testcase dec_bitwise_ops_3.f90 is a good test of this:
it uses -fdec -fno-dec -std=legacy to avoid warnings for XOR. With the
version posted previously, the -std=legacy is overwritten by -fno-dec
and warnings still appear. Here's what I'd change from the previous
patch to support this:
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index af89a5d2faf..b7f7360215c 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -66,16 +66,6 @@ set_default_std_flags (void)
static void
set_dec_flags (int value)
{
- /* Allow legacy code without warnings.
- Nb. We do not unset the allowed standards with value == 0 because
- they are set by default in set_default_std_flags. */
- if (value)
- gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL
- | GFC_STD_GNU | GFC_STD_LEGACY;
-
- SET_BITFLAG (gfc_option.warn_std, !value, GFC_STD_LEGACY);
- SET_BITFLAG (gfc_option.warn_std, !value, GFC_STD_F95_DEL);
-
/* Set (or unset) other DEC compatibility extensions. */
SET_BITFLAG (flag_dollar_ok, value, value);
SET_BITFLAG (flag_cray_pointer, value, value);
@@ -85,6 +75,24 @@ set_dec_flags (int value)
SET_BITFLAG (flag_dec_math, 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
@@ -248,6 +256,9 @@ gfc_post_options (const char **pfilename)
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)
@@
Post by Jakub JelinekDirectives are only processed in the current file, so it doesn't really
matter what the included file has as directives. One could even have the
included one be with expected dg-error lines and then include it in
the ones that don't expect any.
Good to know, thanks! In that case, I like your suggestion of reducing
the test cases to includes. See new the newly attached patch for
updated cases.
Post by Jakub JelinekAnyway, that is all from me, I still don't want to stomp on Fortran
maintainer's review (use my global reviewer's rights for that) and
thus I'm deferring the review to them. When committing, please make sure
to include Mark's email in the ChangeLog next to yours to credit him.
Thanks for your comments. I think nobody will feel stomped on since
maintainers are sparse and busy. I will certainly make note of Mark's
contributions when committing.
Attached is the latest version, which builds and regtests cleanly on
x86_64-redhat-linux. OK for trunk, 7-branch, and 8-branch?
Fritz
From 1cae11a88b29fe521e0e6c6c7c1796a7adb34cad Mon Sep 17 00:00:00 2001
From: Fritz Reese <***@gmail.com>
Date: Mon, 12 Nov 2018 13:57:25 -0500
Subject: [PATCH] PR fortran/87919
Fix handling -fno-* prefix for init-local-zero, check-array-temporaries and dec.
gcc/fortran/
* 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/testsuiste/
* 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.
---
gcc/fortran/options.c | 93 +++++++++++++++--------
gcc/testsuite/gfortran.dg/array_temporaries_5.f90 | 10 +++
gcc/testsuite/gfortran.dg/dec_bitwise_ops_3.f90 | 29 +++++++
gcc/testsuite/gfortran.dg/dec_d_lines_3.f | 14 ++++
gcc/testsuite/gfortran.dg/dec_exp_4.f90 | 12 +++
gcc/testsuite/gfortran.dg/dec_exp_5.f90 | 11 +++
gcc/testsuite/gfortran.dg/dec_io_7.f90 | 20 +++++
gcc/testsuite/gfortran.dg/dec_structure_24.f90 | 32 ++++++++
gcc/testsuite/gfortran.dg/dec_structure_25.f90 | 11 +++
gcc/testsuite/gfortran.dg/dec_structure_26.f90 | 34 +++++++++
gcc/testsuite/gfortran.dg/dec_structure_27.f90 | 34 +++++++++
gcc/testsuite/gfortran.dg/dec_type_print_3.f90 | 21 +++++
gcc/testsuite/gfortran.dg/init_flag_20.f90 | 15 ++++
13 files changed, 306 insertions(+), 30 deletions(-)
create mode 100644 gcc/testsuite/gfortran.dg/array_temporaries_5.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_bitwise_ops_3.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_d_lines_3.f
create mode 100644 gcc/testsuite/gfortran.dg/dec_exp_4.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_exp_5.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_io_7.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_structure_24.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_structure_25.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_structure_26.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_structure_27.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_type_print_3.f90
create mode 100644 gcc/testsuite/gfortran.dg/init_flag_20.f90