Debian Codegraph @

gcc/testsuite/gfortran.dg/allocate_error_5.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-fcheck=mem" }
3 ! { dg-shouldfail "Fortran runtime error: Assignment of scalar to unallocated array" }
4 !
5 ! This omission was encountered in the course of fixing PR54070. Whilst this is a
6 ! very specific case, others such as allocatable components have been tested.
7 !
8 ! Contributed by Tobias Burnus <[email protected]>
9 !
10 function g(a) result (res)
11 character(len=*) :: a
12 character(len=:),allocatable :: res(:)
13 res = a ! Since 'res' is not allocated, a runtime error should occur.
14 end function
15
16 interface
17 function g(a) result(res)
18 character(len=*) :: a
19 character(len=:),allocatable :: res(:)
20 end function
21 end interface
22 print *, g("ABC")
23 end