From: Mark Eggleston Date: Mon, 11 May 2020 11:38:14 +0000 (+0100) Subject: Fortran : Spurious warning message with -Wsurprising PR59107 X-Git-Tag: misc/first-auto-changelog-9~42 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a17beaecadf10d1c9c44d2b31eedc11dfdea35a;p=thirdparty%2Fgcc.git Fortran : Spurious warning message with -Wsurprising PR59107 This change is from a patch developed for gcc-5. The code has moved on since then requiring a change to interface.c 2020-05-11 Mark Eggleston Backported from mainline 2020-05-11 Janus Weil Dominique d'Humieres gcc/fortran/ PR fortran/59107 * gfortran.h: Rename field resolved as resolve_symbol_called and assign two 2 bits instead of 1. * interface.c (gfc_find_typebound_dtio_proc): Use new field name. * resolve.c (gfc_resolve_intrinsic): Replace check of the formal field with resolve_symbol_called is at least 2, if it is not set the field to 2. (resolve_typebound_procedure): Use new field name. (resolve_symbol): Use new field name and check whether it is at least 1, if it is not set the field to 1. Backported from mainline 2020-05-11 Mark Eggleston gcc/testsuite/ PR fortran/59107 * gfortran.dg/pr59107.f90: New test. --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 21f8b1afa79b..2255be74128e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,19 @@ +2020-05-11 Mark Eggleston + + Backported from mainline + 2020-05-11 Janus Weil + Dominique d'Humieres + + PR fortran/59107 + * gfortran.h: Rename field resolved as resolve_symbol_called + and assign two 2 bits instead of 1. + * interface.c (gfc_find_typebound_dtio_proc): Use new field name. + * resolve.c (gfc_resolve_intrinsic): Replace check of the formal + field with resolve_symbol_called is at least 2, if it is not + set the field to 2. (resolve_typebound_procedure): Use new field + name. (resolve_symbol): Use new field name and check whether it + is at least 1, if it is not set the field to 1. + 2020-05-04 Tobias Burnus Backport from mainline. diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index d7071ae5fcf5..a3320d890cd4 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -1602,7 +1602,10 @@ typedef struct gfc_symbol /* Set if the symbol is used in a function result specification . */ unsigned fn_result_spec:1; /* Used to avoid multiple resolutions of a single symbol. */ - unsigned resolved:1; + /* = 2 if this has already been resolved as an intrinsic, + in gfc_resolve_intrinsic, + = 1 if it has been resolved in resolve_symbol. */ + unsigned resolve_symbol_called:2; /* Set if this is a module function or subroutine with the abreviated declaration in a submodule. */ unsigned abr_modproc_decl:1; diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index b5701b1a59a1..29af409dde00 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -4979,7 +4979,8 @@ gfc_find_typebound_dtio_proc (gfc_symbol *derived, bool write, bool formatted) gfc_symtree *tb_io_st = NULL; bool t = false; - if (!derived || !derived->resolved || derived->attr.flavor != FL_DERIVED) + if (!derived || !derived->resolve_symbol_called + || derived->attr.flavor != FL_DERIVED) return NULL; /* Try to find a typebound DTIO binding. */ diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index c041d8df96d4..0e594ffadb0b 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -1754,9 +1754,11 @@ gfc_resolve_intrinsic (gfc_symbol *sym, locus *loc) gfc_intrinsic_sym* isym = NULL; const char* symstd; - if (sym->formal) + if (sym->resolve_symbol_called >= 2) return true; + sym->resolve_symbol_called = 2; + /* Already resolved. */ if (sym->from_intmod && sym->ts.type != BT_UNKNOWN) return true; @@ -13570,7 +13572,7 @@ resolve_typebound_procedure (gfc_symtree* stree) { /* If proc has not been resolved at this point, proc->name may actually be a USE associated entity. See PR fortran/89647. */ - if (!proc->resolved + if (!proc->resolve_symbol_called && proc->attr.function == 0 && proc->attr.subroutine == 0) { gfc_symbol *tmp; @@ -14820,9 +14822,9 @@ resolve_symbol (gfc_symbol *sym) gfc_array_spec *as; bool saved_specification_expr; - if (sym->resolved) + if (sym->resolve_symbol_called >= 1) return; - sym->resolved = 1; + sym->resolve_symbol_called = 1; /* No symbol will ever have union type; only components can be unions. Union type declaration symbols have type BT_UNKNOWN but flavor FL_UNION diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 02b5dbc6ea80..a3dc4a9748ae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2020-05-11 Mark Eggleston + + Backported from mainline + 2020-05-11 Mark Eggleston + + PR fortran/59107 + * gfortran.dg/pr59107.f90: New test. + 2020-05-07 Jakub Jelinek PR c++/94946 diff --git a/gcc/testsuite/gfortran.dg/pr59107.f90 b/gcc/testsuite/gfortran.dg/pr59107.f90 new file mode 100644 index 000000000000..a84328f08519 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr59107.f90 @@ -0,0 +1,11 @@ +! { dg-compile } +! { dg-options "-Wsurprising" } + +! There should be no surprising warnings + +program p + Integer :: nargs + intrinsic :: command_argument_count + nargs = command_argument_count() +end +