From: Mikael Morin Date: Mon, 17 Jul 2023 12:13:01 +0000 (+0200) Subject: fortran: Remove commented out assertion X-Git-Tag: basepoints/gcc-15~7573 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dee3518b7fed0cba45018bac1e4f4549e6ec69a2;p=thirdparty%2Fgcc.git fortran: Remove commented out assertion r13-6747-gd7caf313525a46f200d7f5db1ba893f853774aee commented out an assertion without any test exercising it. This adds such a test where the assertion would fail, and removes the commented code. gcc/fortran/ChangeLog: * trans.cc (gfc_build_final_call): Remove commented assertion. gcc/testsuite/ChangeLog: * gfortran.dg/finalize_53.f90: New test. --- diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index f1a3aacd8503..387d66a112f9 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1126,7 +1126,6 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var, else { gfc_conv_expr (&se, var); -// gcc_assert (se.pre.head == NULL_TREE && se.post.head == NULL_TREE); array = se.expr; /* No copy back needed, hence set attr's allocatable/pointer diff --git a/gcc/testsuite/gfortran.dg/finalize_53.f90 b/gcc/testsuite/gfortran.dg/finalize_53.f90 new file mode 100644 index 000000000000..eeacb9eef9c5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/finalize_53.f90 @@ -0,0 +1,34 @@ +! { dg-do compile } +! +! Check that the data reference preliminary code is properly +! generated and accepted by the finalization handling code. + +module m + implicit none + type t + integer :: i + contains + final :: finalize_t + end type t + logical :: finalize_called = .false. +contains + subroutine finalize_t(a) + type(t) :: a + finalize_called = .true. + end subroutine finalize_t +end module m +program p + use m + type u + type(t), allocatable :: ta + end type u + class(u), allocatable :: c(:) + integer, allocatable :: a(:), b(:) + a = [1, 2, 3] + b = [3, 5, 1] + allocate(c, source = [u(t(1)), u(t(9))]) + deallocate(c(count(a + b == 4))%ta) + if (.not. allocated (c(1)%ta)) stop 11 + if (allocated (c(2)%ta)) stop 12 + if (.not. finalize_called) stop 13 +end program p