coarray_41.f90: Add "-latomic" option if libatomic_available.
[official-gcc.git] / gcc / testsuite / gfortran.dg / allocate_with_source_18.f03
blob746bd0ddd66d2554222e4dc1a9fb517cb3c5cd84
1 ! { dg-do run }
3 ! PR fortran/57365
4 ! [OOP] Sourced allocation fails with unlimited polymorphism
5 ! Contributed by <rxs@hotmail.de>
7 program bug
9     implicit none
10     character(len=:), allocatable :: test
12     test = "A test case"
13     call allocate_test(test)
14     deallocate(test)
16 contains
18     subroutine allocate_test(var)
19         class(*) :: var
20         class(*), pointer :: copyofvar
21         allocate(copyofvar, source=var)
22         select type (copyofvar)
23             type is (character(len=*))
24 !                print*, len(copyofvar), copyofvar
25                 if (len(copyofvar) /= 11) call abort ()
26                 if (copyofvar /= "A test case") call abort ()
27         end select
28         deallocate(copyofvar)
29     end subroutine
31 end program bug