summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/widechar_5.f90
blob: ed2f32fbd09ba4d2e10ac5e74d1ac27fc2c54184 (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
55
56
57
58
59
! { dg-do run }
! { dg-options "-fbackslash" }

module kinds
  implicit none
  integer, parameter :: one = 1, four = 4
end module kinds

module inner
  use kinds
  implicit none
  character(kind=one,len=*), parameter :: inner1 = "abcdefg \xEF kl"
  character(kind=four,len=*), parameter :: &
        inner4 = 4_"\u9317x \U001298cef   dea\u10De"
end module inner

module middle
  use inner
  implicit none
  character(kind=one,len=len(inner1)), dimension(2,2), parameter :: middle1 &
    = reshape ([ character(kind=one,len=len(inner1)) :: inner1, ""], &
               [ 2, 2 ], &
               [ character(kind=one,len=len(inner1)) :: "foo", "ba " ])
  character(kind=four,len=len(inner4)), dimension(2,2), parameter :: middle4 &
    = reshape ([ character(kind=four,len=len(inner4)) :: inner4, 4_""], &
               [ 2, 2 ], &
               [ character(kind=four,len=len(inner4)) :: 4_"foo", 4_"ba " ])
end module middle

module outer
  use middle
  implicit none
  character(kind=one,len=*), parameter :: my1(2) = middle1(1,:)
  character(kind=four,len=*), parameter :: my4(2) = middle4(1,:)
end module outer

program test_modules
  use outer, outer1 => my1, outer4 => my4
  implicit none

  if (len (inner1) /= len(inner4)) call abort
  if (len (inner1) /= len_trim(inner1)) call abort
  if (len (inner4) /= len_trim(inner4)) call abort

  if (len(middle1) /= len(inner1)) call abort
  if (len(outer1) /= len(inner1)) call abort
  if (len(middle4) /= len(inner4)) call abort
  if (len(outer4) /= len(inner4)) call abort

  if (any (len_trim (middle1) /= reshape([len(middle1), 0, 3, 2], [2,2]))) &
    call abort
  if (any (len_trim (middle4) /= reshape([len(middle4), 0, 3, 2], [2,2]))) &
    call abort
  if (any (len_trim (outer1) /= [len(outer1), 3])) call abort
  if (any (len_trim (outer4) /= [len(outer4), 3])) call abort

end program test_modules

! { dg-final { cleanup-modules "kinds inner middle outer" } }