Debian Codegraph @

gcc/testsuite/gfortran.dg/dec_io_6.f90

raw
1 ! { dg-do run }
2 ! { dg-options "-fdec" }
3 !
4 ! Test that we get a run-time warning for close-on-delete with READONLY,
5 ! and that the file is protected from deletion.
6 !
7
8 implicit none
9
10 integer :: fd = 8
11 character(*), parameter :: f = "dec_io_6.txt"
12 logical :: exists
13
14 open(unit=fd,file=f,action='write')
15 close(unit=fd)
16
17 open(unit=fd,file=f,action='read',readonly)
18 close(unit=fd,status='delete') ! { dg-output "file protected by READONLY" }
19
20 inquire(file=f, EXIST=exists)
21 if (.not. exists) then
22 print *, 'file was not protected by READONLY!'
23 STOP 1
24 endif
25
26 open(unit=fd,file=f,action='write')
27 close(unit=fd,status='delete') ! cleanup
28
29 end