| 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 |
real :: a |
| 12 |
real,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 |
real :: a |
| 19 |
real,allocatable :: res(:) |
| 20 |
end function |
| 21 |
end interface |
| 22 |
! print *, g(2.0) |
| 23 |
! call foo |
| 24 |
call foofoo |
| 25 |
contains |
| 26 |
subroutine foo |
| 27 |
type bar |
| 28 |
real, allocatable, dimension(:) :: r |
| 29 |
end type |
| 30 |
type (bar) :: foobar |
| 31 |
foobar%r = 1.0 |
| 32 |
end subroutine |
| 33 |
subroutine foofoo |
| 34 |
type barfoo |
| 35 |
character(:), allocatable, dimension(:) :: c |
| 36 |
end type |
| 37 |
type (barfoo) :: foobarfoo |
| 38 |
foobarfoo%c = "1.0" |
| 39 |
end subroutine |
| 40 |
end |