Re: [Patch, Fortran, OOP] PR 58175: Incorrect warning message on scalar finalizer
I have just committed as obvious a minor addition here: https://gcc.gnu.org/viewcvs?rev=243218=gcc=rev It deals with an extended test case that was only reported after the initial fix. Cheers, Janus 2016-11-29 15:16 GMT+01:00 Janus Weil: > Committed as r242960. > > > > 2016-11-28 14:36 GMT+01:00 Janus Weil : >> Hi all, >> >> the attached patch was posted on bugzilla by Tobias three years ago, >> but left unattended since then. It is simple, works well (fixing a >> bogus warning) and regtests cleanly on x86_64-linux-gnu. >> >> If no one objects, I will commit this to trunk by tomorrow. >> >> Cheers, >> Janus >> >> >> >> 2016-11-28 Tobias Burnus >> >> PR fortran/58175 >> * resolve.c (gfc_resolve_finalizers): Properly detect scalar finalizers. >> >> 2016-11-28 Janus Weil >> >> PR fortran/58175 >> * gfortran.dg/finalize_30.f90: New test case. Index: gcc/fortran/resolve.c === --- gcc/fortran/resolve.c (revision 243217) +++ gcc/fortran/resolve.c (working copy) @@ -12517,7 +12517,7 @@ error: /* Warn if we haven't seen a scalar finalizer procedure (but we know there were nodes in the list, must have been for arrays. It is surely a good idea to have a scalar version there if there's something to finalize. */ - if (warn_surprising && result && !seen_scalar) + if (warn_surprising && derived->f2k_derived->finalizers && !seen_scalar) gfc_warning (OPT_Wsurprising, "Only array FINAL procedures declared for derived type %qs" " defined at %L, suggest also scalar one", Index: gcc/testsuite/gfortran.dg/finalize_30.f90 === --- gcc/testsuite/gfortran.dg/finalize_30.f90 (revision 243217) +++ gcc/testsuite/gfortran.dg/finalize_30.f90 (working copy) @@ -10,6 +10,8 @@ module ct contains final :: aD end type + type, extends(a) :: a1 + end type contains subroutine aD(self) type(a), intent(inout) :: self
Re: [Patch, Fortran, OOP] PR 58175: Incorrect warning message on scalar finalizer
Committed as r242960. 2016-11-28 14:36 GMT+01:00 Janus Weil: > Hi all, > > the attached patch was posted on bugzilla by Tobias three years ago, > but left unattended since then. It is simple, works well (fixing a > bogus warning) and regtests cleanly on x86_64-linux-gnu. > > If no one objects, I will commit this to trunk by tomorrow. > > Cheers, > Janus > > > > 2016-11-28 Tobias Burnus > > PR fortran/58175 > * resolve.c (gfc_resolve_finalizers): Properly detect scalar finalizers. > > 2016-11-28 Janus Weil > > PR fortran/58175 > * gfortran.dg/finalize_30.f90: New test case.
[Patch, Fortran, OOP] PR 58175: Incorrect warning message on scalar finalizer
Hi all, the attached patch was posted on bugzilla by Tobias three years ago, but left unattended since then. It is simple, works well (fixing a bogus warning) and regtests cleanly on x86_64-linux-gnu. If no one objects, I will commit this to trunk by tomorrow. Cheers, Janus 2016-11-28 Tobias BurnusPR fortran/58175 * resolve.c (gfc_resolve_finalizers): Properly detect scalar finalizers. 2016-11-28 Janus Weil PR fortran/58175 * gfortran.dg/finalize_30.f90: New test case. Index: gcc/fortran/resolve.c === --- gcc/fortran/resolve.c (revision 242908) +++ gcc/fortran/resolve.c (working copy) @@ -12395,6 +12395,9 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool /* Skip this finalizer if we already resolved it. */ if (list->proc_tree) { + if (list->proc_tree->n.sym->formal->sym->as == NULL + || list->proc_tree->n.sym->formal->sym->as->rank == 0) + seen_scalar = true; prev_link = &(list->next); continue; } @@ -12489,7 +12492,7 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool } /* Is this the/a scalar finalizer procedure? */ - if (!arg->as || arg->as->rank == 0) + if (my_rank == 0) seen_scalar = true; /* Find the symtree for this procedure. */ ! { dg-do compile } ! { dg-options "-Wsurprising" } ! ! PR 58175: [OOP] Incorrect warning message on scalar finalizer ! ! Contributed by Andrew Benson module ct type :: a contains final :: aD end type contains subroutine aD(self) type(a), intent(inout) :: self end subroutine end module program test use ct end