2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / char_pointer_comp_assign.f90
blob4e2d853b185c51ae3d926108e88f7d7777ba503a
1 ! { dg-do run }
2 ! This test the fix of PR18283, where assignments of scalar,
3 ! character pointer components of derived types caused an ICE.
4 ! It also checks that the array counterparts remain operational.
5 ! Contributed by Paul Thomas pault@gcc.gnu.org
7 program char_pointer_comp_assign
8 implicit none
9 type :: dt
10 character (len=4), pointer :: scalar
11 character (len=4), pointer :: array(:)
12 end type dt
13 type (dt) :: a
14 character (len=4), target :: scalar_t ="abcd"
15 character (len=4), target :: array_t(2) = (/"abcd","efgh"/)
17 ! Do assignments first
18 allocate (a%scalar, a%array(2))
19 a%scalar = scalar_t
20 if (a%scalar /= "abcd") call abort ()
21 a%array = array_t
22 if (any(a%array /= (/"abcd","efgh"/))) call abort ()
23 deallocate (a%scalar, a%array)
25 ! Now do pointer assignments.
26 a%scalar => scalar_t
27 if (a%scalar /= "abcd") call abort ()
28 a%array => array_t
29 if (any(a%array /= (/"abcd","efgh"/))) call abort ()
31 end program char_pointer_comp_assign