1! { dg-do run } 2! Test for allocatable scalar components and deferred length char arrays. 3! Check that fix for pr61275 works. 4! Contributed by Antony Lewis <antony@cosmologist.info> and 5! Andre Vehreschild <vehre@gmx.de> 6! 7module typeA 8 Type A 9 integer :: X 10 integer, allocatable :: y 11 character(len=:), allocatable :: c 12 end type A 13end module 14 15program test_allocatable_components 16 use typeA 17 Type(A) :: Me 18 Type(A) :: Ea 19 20 Me= A(X= 1, Y= 2, C="correctly allocated") 21 22 if (Me%X /= 1) STOP 1 23 if (.not. allocated(Me%y) .or. Me%y /= 2) STOP 2 24 if (.not. allocated(Me%c)) STOP 3 25 if (len(Me%c) /= 19) STOP 4 26 if (Me%c /= "correctly allocated") STOP 5 27 28 ! Now check explicitly allocated components. 29 Ea%X = 9 30 allocate(Ea%y) 31 Ea%y = 42 32 ! Implicit allocate on assign in the next line 33 Ea%c = "13 characters" 34 35 if (Ea%X /= 9) STOP 6 36 if (.not. allocated(Ea%y) .or. Ea%y /= 42) STOP 7 37 if (.not. allocated(Ea%c)) STOP 8 38 if (len(Ea%c) /= 13) STOP 9 39 if (Ea%c /= "13 characters") STOP 10 40 41 deallocate(Ea%y) 42 deallocate(Ea%c) 43 if (allocated(Ea%y)) STOP 11 44 if (allocated(Ea%c)) STOP 12 45end program 46 47