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"  <werner.blokbuster@gmail.com>
6!
7module 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
18contains
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
27end module u
28
29
30submodule (u) z
31
32    implicit none
33
34contains
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
43end submodule z
44
45
46program 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
54end program test_uniq
55