OSDN Git Service

2010-02-10 Joost VandeVondele <jv244@cam.ac.uk>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / char_cast_2.f90
1 ! { dg-do compile }
2 ! { dg-options "-fdump-tree-original" }
3 ! This is the same as achar_4.f90 but checks that the result of the 'merge'
4 ! reference is correctly cast.
5 !
6 ! The code comes from http://www.star.le.ac.uk/~cgp/fortran.html (by Clive Page)
7 ! Reported by Thomas Koenig <tkoenig@gcc.gnu.org>
8 !
9   if (any (Up ("AbCdEfGhIjKlM") .ne. (/"ABCDEFGHIJKLM"/))) call abort ()
10 contains
11   Character (len=20) Function Up (string)
12     Character(len=*) string
13     Up =                                                                &
14      transfer(merge(achar(iachar(transfer(string,"x",len(string)))-     &
15      (ichar('a')-ichar('A')) ),                                         &
16      transfer(string,"x",len(string)) ,                                 &
17      transfer(string,"x",len(string)) >= "a" .and.                      &
18      transfer(string,"x",len(string)) <= "z"), repeat("x", len(string)))
19     return
20   end function Up
21 end
22 ! The sign that all is well is that [S.5][1] appears twice.
23 ! Platform dependent variations are [S$5][1], [__S_5][1], [S___5][1]
24 ! so we count the occurrences of 5][1].
25 ! { dg-final { scan-tree-dump-times "5\\\]\\\[1\\\]" 2 "original" } }
26 ! { dg-final { cleanup-tree-dump "original" } }