PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / alloc_comp_assign_13.f08
blobd6a22475ad1b31e75c89674002d4ba7d6c39f1ab
1 ! { dg-do run }
2 ! Test for allocatable scalar components and deferred length char arrays.
3 ! Check that fix for pr60357 works.
4 ! Contributed by Antony Lewis <antony@cosmologist.info> and
5 !                Andre Vehreschild <vehre@gmx.de>
7 program test_allocatable_components
8     Type A
9         integer :: X
10         integer, allocatable :: y
11         character(len=:), allocatable :: c
12     end type A
13     Type(A) :: Me
14     Type(A) :: Ea
16     Me= A(X= 1, Y= 2, C="correctly allocated")
18     if (Me%X /= 1) STOP 1
19     if (.not. allocated(Me%y) .or. Me%y /= 2) STOP 2
20     if (.not. allocated(Me%c)) STOP 3
21     if (len(Me%c) /= 19) STOP 4
22     if (Me%c /= "correctly allocated") STOP 5
24     ! Now check explicitly allocated components.
25     Ea%X = 9
26     allocate(Ea%y)
27     Ea%y = 42
28     ! Implicit allocate on assign in the next line
29     Ea%c = "13 characters"
31     if (Ea%X /= 9) STOP 6
32     if (.not. allocated(Ea%y) .or. Ea%y /= 42) STOP 7
33     if (.not. allocated(Ea%c)) STOP 8
34     if (len(Ea%c) /= 13) STOP 9
35     if (Ea%c /= "13 characters") STOP 10
37     deallocate(Ea%y)
38     deallocate(Ea%c)
39     if (allocated(Ea%y)) STOP 11
40     if (allocated(Ea%c)) STOP 12
41 end program
43 ! vim:ts=4:sts=4:sw=4: