re PR fortran/78741 (ICE in gfc_get_symbol_decl, at fortran/trans-decl.c:1534)
[official-gcc.git] / gcc / testsuite / gfortran.dg / fgetc_2.f90
blob5df75b6389786095e008f3784dfadb2dcd0a9099
1 ! Testcase for the FGETC and FPUTC intrinsics
2 ! { dg-do run }
3 character(len=5) s
4 integer st
6 s = "12345"
7 open(10,status="scratch")
8 write(10,"(A)") "abcde"
9 rewind(10)
10 st = fgetc(10,s)
11 if ((st /= 0) .or. (s /= "a ")) STOP 1
12 st = fgetc(10,s)
13 close(10)
15 open(10,status="scratch")
16 s = "12345"
17 st = fputc(10,s)
18 if (st /= 0) STOP 2
19 st = fputc(10,"2")
20 if (st /= 0) STOP 3
21 st = fputc(10,"3 ")
22 if (st /= 0) STOP 4
23 rewind(10)
24 st = fgetc(10,s)
25 if (s(1:1) /= "1") STOP 5
26 st = fgetc(10,s)
27 if (s(1:1) /= "2") STOP 6
28 st = fgetc(10,s)
29 if ((s(1:1) /= "3") .or. (st /= 0)) STOP 7
30 st = fgetc(10,s)
31 if (st /= -1) STOP 8
32 close (10)
34 ! FGETC and FPUTC on units not opened should not work
35 st = fgetc(12,s)
36 if (st /= -1) STOP 9
37 st = fputc(12,s)
38 if (st /= -1) STOP 10
39 end