| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! Test the fix for PR82814 in which an ICE occurred for the submodule allocation. |
| 4 |
! |
| 5 |
! Contributed by "Werner Blokbuster" <[email protected]> |
| 6 |
! |
| 7 |
module u |
| 8 |
|
| 9 |
implicit none |
| 10 |
|
| 11 |
interface unique |
| 12 |
module function uniq_char(input) result(uniq) |
| 13 |
character(*), intent(in) :: input(:) |
| 14 |
character(size(input)), allocatable :: uniq(:) |
| 15 |
end function uniq_char |
| 16 |
end interface unique |
| 17 |
|
| 18 |
contains |
| 19 |
|
| 20 |
module function uniq2(input) result(uniq) |
| 21 |
character(*), intent(in) :: input(:) |
| 22 |
character(size(input)), allocatable :: uniq(:) |
| 23 |
allocate(uniq(1)) |
| 24 |
uniq = 'A' |
| 25 |
end function uniq2 |
| 26 |
|
| 27 |
end module u |
| 28 |
|
| 29 |
|
| 30 |
submodule (u) z |
| 31 |
|
| 32 |
implicit none |
| 33 |
|
| 34 |
contains |
| 35 |
|
| 36 |
module function uniq_char(input) result(uniq) |
| 37 |
character(*), intent(in) :: input(:) |
| 38 |
character(size(input)), allocatable :: uniq(:) |
| 39 |
allocate(uniq(1)) ! This used to ICE |
| 40 |
uniq = 'A' |
| 41 |
end function uniq_char |
| 42 |
|
| 43 |
end submodule z |
| 44 |
|
| 45 |
|
| 46 |
program test_uniq |
| 47 |
use u |
| 48 |
implicit none |
| 49 |
character(1), dimension(4) :: chr = ['1','2','1','2'] |
| 50 |
|
| 51 |
write(*,*) unique(chr) |
| 52 |
write(*,*) uniq2(chr) |
| 53 |
|
| 54 |
end program test_uniq |