2014-07-12 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / widechar_5.f90
blobece1e4d9cc792a6f4e13ab50bf5beff15cbbc8e8
1 ! { dg-do run }
2 ! { dg-options "-fbackslash" }
4 module kinds
5 implicit none
6 integer, parameter :: one = 1, four = 4
7 end module kinds
9 module inner
10 use kinds
11 implicit none
12 character(kind=one,len=*), parameter :: inner1 = "abcdefg \xEF kl"
13 character(kind=four,len=*), parameter :: &
14 inner4 = 4_"\u9317x \U001298cef dea\u10De"
15 end module inner
17 module middle
18 use inner
19 implicit none
20 character(kind=one,len=len(inner1)), dimension(2,2), parameter :: middle1 &
21 = reshape ([ character(kind=one,len=len(inner1)) :: inner1, ""], &
22 [ 2, 2 ], &
23 [ character(kind=one,len=len(inner1)) :: "foo", "ba " ])
24 character(kind=four,len=len(inner4)), dimension(2,2), parameter :: middle4 &
25 = reshape ([ character(kind=four,len=len(inner4)) :: inner4, 4_""], &
26 [ 2, 2 ], &
27 [ character(kind=four,len=len(inner4)) :: 4_"foo", 4_"ba " ])
28 end module middle
30 module outer
31 use middle
32 implicit none
33 character(kind=one,len=*), parameter :: my1(2) = middle1(1,:)
34 character(kind=four,len=*), parameter :: my4(2) = middle4(1,:)
35 end module outer
37 program test_modules
38 use outer, outer1 => my1, outer4 => my4
39 implicit none
41 if (len (inner1) /= len(inner4)) call abort
42 if (len (inner1) /= len_trim(inner1)) call abort
43 if (len (inner4) /= len_trim(inner4)) call abort
45 if (len(middle1) /= len(inner1)) call abort
46 if (len(outer1) /= len(inner1)) call abort
47 if (len(middle4) /= len(inner4)) call abort
48 if (len(outer4) /= len(inner4)) call abort
50 if (any (len_trim (middle1) /= reshape([len(middle1), 0, 3, 2], [2,2]))) &
51 call abort
52 if (any (len_trim (middle4) /= reshape([len(middle4), 0, 3, 2], [2,2]))) &
53 call abort
54 if (any (len_trim (outer1) /= [len(outer1), 3])) call abort
55 if (any (len_trim (outer4) /= [len(outer4), 3])) call abort
57 end program test_modules