2015-11-15 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / deferred_character_6.f90
blob94afa0c0f285a0acc5292590b60f15397675f8c9
1 ! { dg-do run }
3 ! Tests that PR66408 stays fixed.
5 ! Contributed by <werner.blokbuster@gmail.com>
7 module mytest
9 implicit none
11 type vary
12 character(:), allocatable :: string
13 end type vary
15 interface assignment(=)
16 module procedure char_eq_vary
17 end interface assignment(=)
19 contains
21 subroutine char_eq_vary(my_char,my_vary)
22 character(:), allocatable, intent(out) :: my_char
23 type(vary), intent(in) :: my_vary
24 my_char = my_vary%string
25 end subroutine char_eq_vary
27 end module mytest
30 program thistest
32 use mytest, only: vary, assignment(=)
33 implicit none
35 character(:), allocatable :: test_char
36 character(14), parameter :: str = 'example string'
37 type(vary) :: test_vary
38 type(vary) :: my_stuff
41 test_vary%string = str
42 if (test_vary%string .ne. str) call abort
44 ! This previously gave a blank string.
45 my_stuff%string = test_vary
46 if (my_stuff%string .ne. str) call abort
48 test_char = test_vary
49 if (test_char .ne. str) call abort
51 my_stuff = test_vary
52 if (my_stuff%string .ne. str) call abort
54 end program thistest