2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / index_2.f90
blob74845b96656ef0c89a28b3326848eb7509e35b34
1 ! { dg-do run }
2 ! { dg-options "-fdump-tree-original" }
3 ! PR fortran/36462
5 implicit none
6 character(len=10,kind=1) string1
7 character(len=10,kind=4) string4
8 string1 = 'ABCDEEDCBA'
9 string4 = 'ABCDEEDCBA'
11 if(index(string1,1_'A') /= 1) call abort()
12 if(index(string4,4_'A') /= 1) call abort()
13 if(index(string1,1_'A',kind=4) /= 1_4) call abort()
14 if(index(string4,4_'A',kind=4) /= 1_4) call abort()
15 if(index(string1,1_'A',kind=1) /= 1_1) call abort()
16 if(index(string4,4_'A',kind=1) /= 1_1) call abort()
18 if(index(string1,1_'A',back=.true.) /= 10) call abort()
19 if(index(string4,4_'A',back=.true.) /= 10) call abort()
20 if(index(string1,1_'A',kind=4,back=.true.) /= 10_4) call abort()
21 if(index(string4,4_'A',kind=4,back=.true.) /= 10_4) call abort()
22 if(index(string1,1_'A',kind=1,back=.true.) /= 10_1) call abort()
23 if(index(string4,4_'A',kind=1,back=.true.) /= 10_1) call abort()
25 if(index(string1,1_'A',back=.false.) /= 1) call abort()
26 if(index(string4,4_'A',back=.false.) /= 1) call abort()
27 if(index(string1,1_'A',kind=4,back=.false.) /= 1_4) call abort()
28 if(index(string4,4_'A',kind=4,back=.false.) /= 1_4) call abort()
29 if(index(string1,1_'A',kind=1,back=.false.) /= 1_1) call abort()
30 if(index(string4,4_'A',kind=1,back=.false.) /= 1_1) call abort()
32 if(scan(string1,1_'A') /= 1) call abort()
33 if(scan(string4,4_'A') /= 1) call abort()
34 if(scan(string1,1_'A',kind=4) /= 1_4) call abort()
35 if(scan(string4,4_'A',kind=4) /= 1_4) call abort()
36 if(scan(string1,1_'A',kind=1) /= 1_1) call abort()
37 if(scan(string4,4_'A',kind=1) /= 1_1) call abort()
39 if(scan(string1,1_'A',back=.true.) /= 10) call abort()
40 if(scan(string4,4_'A',back=.true.) /= 10) call abort()
41 if(scan(string1,1_'A',kind=4,back=.true.) /= 10_4) call abort()
42 if(scan(string4,4_'A',kind=4,back=.true.) /= 10_4) call abort()
43 if(scan(string1,1_'A',kind=1,back=.true.) /= 10_1) call abort()
44 if(scan(string4,4_'A',kind=1,back=.true.) /= 10_1) call abort()
46 if(scan(string1,1_'A',back=.false.) /= 1) call abort()
47 if(scan(string4,4_'A',back=.false.) /= 1) call abort()
48 if(scan(string1,1_'A',kind=4,back=.false.) /= 1_4) call abort()
49 if(scan(string4,4_'A',kind=4,back=.false.) /= 1_4) call abort()
50 if(scan(string1,1_'A',kind=1,back=.false.) /= 1_1) call abort()
51 if(scan(string4,4_'A',kind=1,back=.false.) /= 1_1) call abort()
52 end
54 ! { dg-final { scan-tree-dump-times "if ..integer.kind=1.. _gfortran_string_index" 6 "original" } }
55 ! { dg-final { scan-tree-dump-times "if ..integer.kind=1.. _gfortran_string_scan" 6 "original" } }
56 ! { dg-final { cleanup-tree-dump "original" } }