2015-07-03 Christophe Lyon <christophe.lyon@linaro.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / index_2.f90
blob9b92f0acee70d9d21bd4d5a2c432f5ccdc535bfb
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" } }