aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2020-08-10 19:10:26 +0200
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 15:07:55 -0300
commit74cbd48dcd928de8cc60fae9ca345514f074c58a (patch)
tree98441ee58487759bc4e748c084b1266153ba60c4 /gcc/testsuite
parentc2574d63c52a690a703b802142ffaeca115fad84 (diff)
Fix NULL pointer dereference in doloop_contained_function_call.
gcc/fortran/ChangeLog: PR fortran/96556 * frontend-passes.c (doloop_contained_function_call): Do not dereference a NULL pointer for value.function.esym. gcc/testsuite/ChangeLog: PR fortran/96556 * gfortran.dg/do_check_15.f90: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gfortran.dg/do_check_15.f9058
1 files changed, 58 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/do_check_15.f90 b/gcc/testsuite/gfortran.dg/do_check_15.f90
new file mode 100644
index 00000000000..f67452b4660
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/do_check_15.f90
@@ -0,0 +1,58 @@
+! { dg-do compile }
+! PR fortran/96556 - this used to cause an ICE.
+! Test case by Juergen Reuter.
+module polarizations
+
+ implicit none
+ private
+
+ type :: smatrix_t
+ private
+ integer :: dim = 0
+ integer :: n_entry = 0
+ integer, dimension(:,:), allocatable :: index
+ contains
+ procedure :: write => smatrix_write
+ end type smatrix_t
+
+ type, extends (smatrix_t) :: pmatrix_t
+ private
+ contains
+ procedure :: write => pmatrix_write
+ procedure :: normalize => pmatrix_normalize
+ end type pmatrix_t
+
+contains
+
+ subroutine msg_error (string)
+ character(len=*), intent(in), optional :: string
+ end subroutine msg_error
+
+ subroutine smatrix_write (object)
+ class(smatrix_t), intent(in) :: object
+ end subroutine smatrix_write
+
+ subroutine pmatrix_write (object)
+ class(pmatrix_t), intent(in) :: object
+ call object%smatrix_t%write ()
+ end subroutine pmatrix_write
+
+ subroutine pmatrix_normalize (pmatrix)
+ class(pmatrix_t), intent(inout) :: pmatrix
+ integer :: i, hmax
+ logical :: fermion, ok
+ do i = 1, pmatrix%n_entry
+ associate (index => pmatrix%index(:,i))
+ if (index(1) == index(2)) then
+ call error ("diagonal must be real")
+ end if
+ end associate
+ end do
+ contains
+ subroutine error (msg)
+ character(*), intent(in) :: msg
+ call pmatrix%write ()
+ end subroutine error
+ end subroutine pmatrix_normalize
+
+end module polarizations