view gcc/testsuite/gfortran.dg/allocatable_scalar_12.f90 @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children
line wrap: on
line source

! { dg-do run }
!
! PR fortran/47421
!
! Don't auto-deallocatable scalar character allocatables.
!
implicit none
character(len=5), allocatable :: str
allocate(str)
str = '1bcde'
if(str /= '1bcde') STOP 1
call sub(str,len(str))
if(str /= '1bcde') STOP 2
call subOUT(str,len(str))
if (len(str) /= 5) STOP 3
if(allocated(str)) STOP 4
contains
  subroutine sub(x,n)
     integer :: n
     character(len=n), allocatable :: x
     if(len(x) /= 5) STOP 5
     if(x /= '1bcde') STOP 6
  end subroutine sub
  subroutine subOUT(x,n)
     integer :: n
     character(len=n), allocatable,intent(out) :: x
     if(allocated(x)) STOP 7
     if(len(x) /= 5) STOP 8
  end subroutine subOUT
end