https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88190
--- Comment #5 from kargl at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #3)
> With the patch
>
> --- ../_clean/gcc/fortran/options.c 2018-11-21 09:27:43.000000000 +0100
> +++ gcc/fortran/options.c 2018-11-25 21:29:39.000000000 +0100
> @@ -38,12 +38,14 @@ gfc_option_t gfc_option;
> libgfortran/runtime/compile_options.c (init_compile_options). */
>
> static void
> -set_default_std_flags (void)
> +set_default_std_flags (bool legacy)
> {
> 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_GNU | GFC_STD_LEGACY
> + | GFC_STD_F2008_OBS | GFC_STD_GNU
> | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS;
> + if (legacy)
> + gfc_option.allow_std |= GFC_STD_LEGACY;
> gfc_option.warn_std = GFC_STD_F2018_DEL | GFC_STD_F95_DEL |
> GFC_STD_LEGACY;
> }
>
> @@ -129,7 +131,7 @@ gfc_init_options (unsigned int decoded_o
>
> set_dec_flags (0);
>
> - set_default_std_flags ();
> + set_default_std_flags (false);
>
> /* Initialize cpp-related options. */
> gfc_cpp_init_options (decoded_options_count, decoded_options);
> @@ -742,11 +744,11 @@ gfc_handle_option (size_t scode, const c
> break;
>
> case OPT_std_gnu:
> - set_default_std_flags ();
> + set_default_std_flags (false);
> break;
>
> case OPT_std_legacy:
> - set_default_std_flags ();
> + set_default_std_flags (true);
> gfc_option.warn_std = 0;
> break;
>
>
> I see 683 new failures. Grepping the Fortran code for GFC_STD_LEGACY I get
>
> gcc/fortran/array.c: if (!gfc_notify_std (GFC_STD_LEGACY,
> "AC-IMPLIED-DO initial "
> gcc/fortran/array.c: if (!gfc_notify_std (GFC_STD_LEGACY,
> "AC-IMPLIED-DO final "
> gcc/fortran/array.c: if (!gfc_notify_std (GFC_STD_LEGACY,
> "AC-IMPLIED-DO step "
> gcc/fortran/decl.c: if (!gfc_notify_std (GFC_STD_LEGACY, "PARAMETER
> without '()' at %C"))
> gcc/fortran/decl.c: if (!gfc_notify_std (GFC_STD_LEGACY, "Blanket SAVE
> statement at %C "
> gcc/fortran/decl.c: if (!gfc_notify_std (GFC_STD_LEGACY, "SAVE
> statement at %C follows "
> gcc/fortran/error.c: else if (std & GFC_STD_LEGACY)
> gcc/fortran/gfortran.texi:(32), @code{GFC_STD_LEGACY} (64),
> @code{GFC_STD_F2008} (128),
> gcc/fortran/gfortran.texi:GFC_STD_F2018_OBS | GFC_STD_F2018_DEL |
> GFC_STD_GNU | GFC_STD_LEGACY}.
> gcc/fortran/gfortran.texi:standard error. Default: @code{GFC_STD_F95_DEL |
> GFC_STD_LEGACY}.
> gcc/fortran/intrinsic.c: if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0)
> gcc/fortran/intrinsic.c: BT_INTEGER, gfc_integer_kinds[i].kind,
> GFC_STD_LEGACY);
> gcc/fortran/intrinsic.c: BT_REAL, gfc_real_kinds[i].kind,
> GFC_STD_LEGACY);
> gcc/fortran/intrinsic.c: BT_COMPLEX, gfc_real_kinds[i].kind,
> GFC_STD_LEGACY);
> gcc/fortran/intrinsic.c: gfc_default_character_kind,
> GFC_STD_LEGACY);
> gcc/fortran/intrinsic.c: BT_LOGICAL, gfc_logical_kinds[i].kind,
> GFC_STD_LEGACY);
> gcc/fortran/intrinsic.c: if ((gfc_option.allow_std & GFC_STD_LEGACY) != 0)
> gcc/fortran/intrinsic.c: BT_LOGICAL,
> gfc_logical_kinds[j].kind,
> GFC_STD_LEGACY);
> gcc/fortran/intrinsic.c: BT_INTEGER,
> gfc_integer_kinds[i].kind,
> GFC_STD_LEGACY);
> gcc/fortran/intrinsic.c: case GFC_STD_LEGACY:
> gcc/fortran/io.c: /* If rank is nonzero and type is not character, we allow
> it under GFC_STD_LEGACY.
> gcc/fortran/io.c: if (!gfc_notify_std (GFC_STD_LEGACY, "Non-character
> in FORMAT tag "
> gcc/fortran/io.c: && !gfc_notify_std (GFC_STD_LEGACY, "Comma before i/o
> item list at %L",
> gcc/fortran/libgfortran.h:#define GFC_STD_LEGACY (1<<6) /*
> Backward
> compatibility. */
> gcc/fortran/match.c: if (!gfc_notify_std (GFC_STD_LEGACY,
> ".XOR. operator at %C"))
> gcc/fortran/options.c: gfc_option.allow_std |= GFC_STD_LEGACY;
> gcc/fortran/options.c: gfc_option.warn_std = GFC_STD_F2018_DEL |
> GFC_STD_F95_DEL | GFC_STD_LEGACY;
> gcc/fortran/options.c: | GFC_STD_GNU | GFC_STD_LEGACY;
> gcc/fortran/options.c: gfc_option.warn_std &= ~(GFC_STD_LEGACY |
> GFC_STD_F95_DEL);
> gcc/fortran/options.c: if (pedantic && (gfc_option.allow_std &
> GFC_STD_LEGACY) != 0)
> gcc/fortran/options.c: gfc_option.warn_std |= GFC_STD_F95_OBS |
> GFC_STD_F95_DEL | GFC_STD_LEGACY;
> gcc/fortran/primary.c: if (!gfc_notify_std (GFC_STD_LEGACY, "Hollerith
> constant at %C"))
> gcc/fortran/primary.c: if (!gfc_notify_std (GFC_STD_LEGACY, "%%LOC() as
> an rvalue at %C"))
> gcc/fortran/resolve.c: || ((gfc_option.warn_std & GFC_STD_LEGACY)
> gcc/fortran/resolve.c: if (!gfc_notify_std (GFC_STD_LEGACY, "REAL array
> index at %L",
> gcc/fortran/resolve.c: gfc_notify_std (GFC_STD_LEGACY, "Label at %L is not
> in the same block "
> gcc/fortran/symbol.c: if (attr->automatic && !gfc_notify_std
> (GFC_STD_LEGACY,
> gcc/fortran/symbol.c: if (!gfc_notify_std (GFC_STD_LEGACY,
> gcc/fortran/symbol.c: if (!gfc_notify_std (GFC_STD_LEGACY,
> gcc/fortran/symbol.c: if (!gfc_notify_std (GFC_STD_LEGACY,
> gcc/fortran/symbol.c: if (!gfc_notify_std (GFC_STD_LEGACY,
> gcc/fortran/symbol.c: if (!gfc_notify_std (GFC_STD_LEGACY,
>
> My next step will be to check that replacing GFC_STD_LEGACY with GFC_STD_GNU
> restores the previous behavior.
>
> Meanwhile It will helpful to discuss what we want to keep as GFC_STD_LEGACY,
> the failing test being fixed by some { dg-options "-std=legacy -pedantic" }.
Before you go any further, you need to clearly define
what is meant by GFC_STD_LEGACY and GFC_STD_GNU. These
two have been intertwined because contributors could
elect to place something behind LEGACY or GNU (and sometimes
a contributor chose neither!).
Consider,
% cat a.f
program foo
real*4 x
do 1 x = 1, 2
print *, x + '1234'x + x'4321'
1 continue
end
real*4 GNU extension, accepted with -std=gnu or legacy
real do-loop index F95 deleted feature, accepted only with -std=legacy
'1234'x GNU extension, postfixed BOZ indicator, -std=gnu or legacy
x'1234' Nonstandard BOZ prefix. No -std= identifies issue.
% gfcx -c a.f
a.f:3:10:
3 | do 1 x = 1, 2
| 1
Warning: Deleted feature: Loop variable at (1) must be integer
% gfcx -c -std=gnu a.f
a.f:3:10:
3 | do 1 x = 1, 2
| 1
Warning: Deleted feature: Loop variable at (1) must be integer
% gfcx -c -std=legacy a.f
Replacing LEGACY with GNU will now silently accept deleted features.
That is BAD, BAD, BAD.