From c0fe5a210968518a05a32c813e645f162f35201f Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Tue, 29 Nov 2016 15:15:29 +0100 Subject: [PATCH] [multiple changes] 2016-11-29 Tobias Burnus PR fortran/58175 * resolve.c (gfc_resolve_finalizers): Properly detect scalar finalizers. 2016-11-29 Janus Weil PR fortran/58175 * gfortran.dg/finalize_30.f90: New test case. From-SVN: r242960 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/resolve.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/finalize_30.f90 | 21 +++++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/finalize_30.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b6e82d75ed5..d0dd3063f9a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-11-29 Tobias Burnus + + PR fortran/58175 + * resolve.c (gfc_resolve_finalizers): Properly detect scalar finalizers. + 2016-11-27 Paul Thomas PR fortran/78474 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 9e628f18a11..152678fbe0b 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -12395,6 +12395,9 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool *finalizable) /* 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 *finalizable) } /* 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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 62f362a65b4..6d7052451a3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-29 Janus Weil + + PR fortran/58175 + * gfortran.dg/finalize_30.f90: New test case. + 2016-11-29 Martin Liska PR gcov-profile/78582 diff --git a/gcc/testsuite/gfortran.dg/finalize_30.f90 b/gcc/testsuite/gfortran.dg/finalize_30.f90 new file mode 100644 index 00000000000..281bfaa0161 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/finalize_30.f90 @@ -0,0 +1,21 @@ +! { 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 -- 2.30.2