aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/submodule_31.f08
blob: 72594d05df39c50e19b95649a1c2bac1a655929a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
! { dg-do run }
!
! Test the fix for PR82814 in which an ICE occurred for the submodule allocation.
!
! Contributed by "Werner Blokbuster"  <werner.blokbuster@gmail.com>
!
module u

    implicit none

    interface unique
        module function uniq_char(input) result(uniq)
            character(*), intent(in) :: input(:)
            character(size(input)), allocatable :: uniq(:)
        end function uniq_char
    end interface unique

contains

    module function uniq2(input) result(uniq)
        character(*), intent(in) :: input(:)
        character(size(input)), allocatable :: uniq(:)
            allocate(uniq(1))
            uniq = 'A'
    end function uniq2

end module u


submodule (u) z

    implicit none

contains

    module function uniq_char(input) result(uniq)
        character(*), intent(in) :: input(:)
        character(size(input)), allocatable :: uniq(:)
            allocate(uniq(1)) ! This used to ICE
            uniq = 'A'
    end function uniq_char

end submodule z


program test_uniq
    use u
    implicit none
    character(1), dimension(4) :: chr = ['1','2','1','2']

    write(*,*) unique(chr)
    write(*,*) uniq2(chr)

end program test_uniq