re PR libfortran/47439 (Fun with scratch files on Windows MKTEMP only allows for...
[official-gcc.git] / gcc / testsuite / gfortran.dg / allocate_derived_1.f90
blob648012431acf244a2ff09af9d4a4b43c3deada1f
1 ! { dg-do compile }
3 ! ALLOCATE statements with derived type specification
5 ! Contributed by Janus Weil <janus@gcc.gnu.org>
7 type :: t1
8 integer :: i
9 end type
11 type, extends(t1) :: t2
12 real :: r
13 end type
15 type, extends(t2) :: t3
16 real :: q
17 end type
19 type, abstract :: u0
20 logical :: nothing
21 end type
23 type :: v1
24 real :: r
25 end type
27 ! FIXME: uncomment and dejagnuify the lines below once class arrays are enabled
28 ! class(t1),dimension(:),allocatable :: x
29 type(t2),dimension(:),allocatable :: y
30 ! class(t3),dimension(:),allocatable :: z
32 ! allocate( x(1))
33 ! allocate(t1 :: x(2))
34 ! allocate(t2 :: x(3))
35 ! allocate(t3 :: x(4))
36 ! allocate(tx :: x(5)) ! { "Error in type-spec at" }
37 ! allocate(u0 :: x(6)) ! { "may not be ABSTRACT" }
38 ! allocate(v1 :: x(7)) ! { "is type incompatible with typespec" }
40 allocate( y(1))
41 allocate(t1 :: y(2)) ! { dg-error "is type incompatible with typespec" }
42 allocate(t2 :: y(3))
43 allocate(t3 :: y(3)) ! { dg-error "is type incompatible with typespec" }
45 ! allocate( z(1))
46 ! allocate(t1 :: z(2)) ! { "is type incompatible with typespec" }
47 ! allocate(t2 :: z(3)) ! { "is type incompatible with typespec" }
48 ! allocate(t3 :: z(4))
50 end