3 ! Check that we reject expressions longer than one character for the
4 ! ICHAR and IACHAR intrinsics.
6 ! Assumed length variables are special because the frontend doesn't have
7 ! an expression for their length
18 character(len
=4) :: addr
22 character(len
=1) :: addr
26 integer, parameter :: j
= 2
27 character(len
=8) :: c
= 'abcd'
28 character(len
=1) :: g1(2)
29 character(len
=1) :: g2(2,2)
30 character*1, parameter :: s1
= 'e'
31 character*2, parameter :: s2
= 'ef'
32 type(derivedtype
) :: dt
33 type(derivedtype1
) :: dt1
35 if (ichar(c(3:3)) /= 97) call abort
36 if (ichar(c(:1)) /= 97) call abort
37 if (ichar(c(j
:j
)) /= 98) call abort
38 if (ichar(s1
) /= 101) call abort
39 if (ichar('f') /= 102) call abort
41 if (ichar(g1(1)) /= 97) call abort
42 if (ichar(g1(1)(:)) /= 97) call abort
44 if (ichar(g2(1,1)) /= 97) call abort
46 i
= ichar(c
) ! { dg-error "must be of length one" "" }
47 i
= ichar(c(:)) ! { dg-error "must be of length one" "" }
48 i
= ichar(s2
) ! { dg-error "must be of length one" "" }
49 i
= ichar(c(1:2)) ! { dg-error "must be of length one" "" }
50 i
= ichar(c(1:)) ! { dg-error "must be of length one" "" }
51 i
= ichar('abc') ! { dg-error "must be of length one" "" }
53 ! ichar and iachar use the same checking routines. DO a couple of tests to
54 ! make sure it's not totally broken.
56 if (ichar(c(3:3)) /= 97) call abort
57 i
= ichar(c
) ! { dg-error "must be of length one" "" }
59 i
= ichar(dt
%addr(1:1))
60 i
= ichar(dt
%addr
) ! { dg-error "must be of length one" "" }
61 i
= ichar(dt
%addr(1:2)) ! { dg-error "must be of length one" "" }
62 i
= ichar(dt
%addr(1:)) ! { dg-error "must be of length one" "" }
64 i
= ichar(dt1
%addr(1:1))