[Patch, Fortran] PR40881 - Add two F95 obsolescence warnings
Mikael Morin
mikael.morin@sfr.fr
Thu Aug 9 12:16:00 GMT 2012
On 08/08/2012 19:12, Tobias Burnus wrote:
> With this patch, I think the only unimplemented obsolescence warning is for
> "(8) Fixed form source -- see B.2.7."
>
> For the latter, I would like to see a possibility to silence that
> warning, given that there is substantial code around, which is in fixed
> form but otherwise a completely valid and obsolescent-free code.
We could silence it with explicit -ffixed-form.
>
> The motivation for implementing this patch was that I did a small
> obsolescent cleanup of our fixed-form code (which uses some Fortran 2003
> features) and I realized that ifort had the "shared DO termination"
> warning and gfortran didn't.
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
More comments below. Regarding the general design, I'm not sure it makes
sense to distinguish between ST_LABEL_DO_TARGET and
ST_LABEL_ENDDO_TARGET. There are no ST_LABEL_GOTO_TARGET or
ST_LABEL_WRITE_TARGET after all.
> diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
> index b6e2975..9670022 100644
> --- a/gcc/fortran/gfortran.h
> +++ b/gcc/fortran/gfortran.h
> @@ -146,8 +146,8 @@ ar_type;
>
> /* Statement label types. */
> typedef enum
> -{ ST_LABEL_UNKNOWN = 1, ST_LABEL_TARGET,
> - ST_LABEL_BAD_TARGET, ST_LABEL_FORMAT
> +{ ST_LABEL_UNKNOWN = 1, ST_LABEL_TARGET, ST_LABEL_DO_TARGET,
> + ST_LABEL_ENDDO_TARGET, ST_LABEL_BAD_TARGET, ST_LABEL_FORMAT
> }
> gfc_sl_type;
Please add a comment explaining the different types; something like:
The labels referenced in DO statements and defined in END DO statements
get types respectively ST_LABEL_DO_TARGET and ST_LABEL_ENDDO_TARGET
instead of the generic ST_LABEL_TARGET so that they can be distinguished
to issue DO-specific diagnostics.
The DO label is a label reference, so ST_LABEL_DO_TARGET is to be used
in gfc_st_label::referenced only. The ST_LABEL_ENDDO_TARGET is the
corresponding label definition, and is to be used in
gfc_st_label::defined only.
> @@ -3825,8 +3828,11 @@ parse_executable (gfc_statement st)
> case ST_NONE:
> unexpected_eof ();
>
> - case ST_FORMAT:
> case ST_DATA:
> + gfc_notify_std (GFC_STD_F95_OBS, "DATA statement at %C after the "
> + "first executable statement");
> + /* Fall through. */
> + case ST_FORMAT:
> case ST_ENTRY:
> case_executable:
> accept_statement (st);
This diagnostic is more appropriate in verify_st_order (which needs to
be called then).
> diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
> index 455e6c9..135c1e5 100644
> --- a/gcc/fortran/symbol.c
> +++ b/gcc/fortran/symbol.c
> @@ -2213,12 +2214,19 @@ gfc_define_st_label (gfc_st_label *lp, gfc_sl_type type, locus *label_locus)
> break;
>
> case ST_LABEL_TARGET:
> + case ST_LABEL_ENDDO_TARGET:
> if (lp->referenced == ST_LABEL_FORMAT)
> gfc_error ("Label %d at %C already referenced as a format label",
> labelno);
> else
> lp->defined = ST_LABEL_TARGET;
I think it should be `lp->defined = type;' here.
> @@ -2254,14 +2262,16 @@ gfc_reference_st_label (gfc_st_label *lp, gfc_sl_type type)
> lp->where = gfc_current_locus;
> }
>
> - if (label_type == ST_LABEL_FORMAT && type == ST_LABEL_TARGET)
> + if (label_type == ST_LABEL_FORMAT
> + && (type == ST_LABEL_TARGET || type == ST_LABEL_DO_TARGET))
> {
> gfc_error ("Label %d at %C previously used as a FORMAT label", labelno);
> rc = FAILURE;
> goto done;
> }
>
> - if ((label_type == ST_LABEL_TARGET || label_type == ST_LABEL_BAD_TARGET)
> + if ((label_type == ST_LABEL_TARGET || label_type == ST_LABEL_DO_TARGET
> + || label_type == ST_LABEL_BAD_TARGET)
> && type == ST_LABEL_FORMAT)
> {
> gfc_error ("Label %d at %C previously used as branch target", labelno);
label_type is initialized using either lp->referenced or lp->defined.
Thus both ST_LABEL_DO_TARGET and ST_LABEL_ENDDO_TARGET should be checked
here. Unless they are merged as suggested above.
Mikael
More information about the Gcc-patches
mailing list