2017-02-20 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / char_cast_1.f90
blob02e695d2d7b738996db6c756d90fc79ee64b9daf
1 ! { dg-do compile }
2 ! { dg-options "-O2 -fdump-tree-original" }
4 ! Check the fix for PR31608 in all it's various manifestations:)
5 ! Contributed by Richard Guenther <rguenth@gcc.gnu.org>
7 character(len=1) :: string = "z"
8 integer :: i(1) = (/100/)
9 print *, Up("abc")
10 print *, transfer(((transfer(string,"x",1))), "x",1)
11 print *, transfer(char(i), "x")
12 print *, Upper ("abcdefg")
13 contains
14 Character (len=20) Function Up (string)
15 Character(len=*) string
16 character(1) :: chr
17 Up = transfer(achar(iachar(transfer(string,chr,1))), "x")
18 return
19 end function Up
20 Character (len=20) Function Upper (string)
21 Character(len=*) string
22 Upper = &
23 transfer(merge(transfer(string,"x",len(string)), &
24 string, .true.), "x")
25 return
26 end function Upper
27 end
28 ! The sign that all is well is that [S.6][1] appears twice.
29 ! Platform dependent variations are [S$6][1], [__S_6][1], [S___6][1]
30 ! { dg-final { scan-tree-dump-times "6\\\]\\\[1\\\]" 2 "original" } }