2017-12-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / allocate_error_6.f90
blobf512bcbd77799f41f73b4bccb125465e25bcb77b
1 ! { dg-do run }
2 ! { dg-additional-options "-fcheck=mem" }
3 ! { dg-shouldfail "Fortran runtime error: Assignment of scalar to unallocated array" }
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.
8 ! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
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
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