Merged with mainline at revision 128810.
[official-gcc.git] / gcc / testsuite / gfortran.dg / open_errors.f90
bloba8d5c2b10d7975f7ee4063c9d4eedf7599c0dd87
1 ! { dg-do run }
2 ! PR30005 Enhanced error messages for OPEN
3 ! Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>
4 character(60) :: msg
5 character(25) :: n = "temptestfile"
6 logical :: there
7 inquire(file=n, exist=there)
8 if (.not.there) then
9 open(77,file=n,status="new")
10 close(77, status="keep")
11 endif
12 msg=""
13 open(77,file=n,status="new", iomsg=msg, iostat=i)
14 if (i == 0) call abort()
15 if (msg /= "File 'temptestfile' already exists") call abort()
17 open(77,file=n,status="old")
18 close(77, status="delete")
19 open(77,file=n,status="old", iomsg=msg, iostat=i)
20 if (i == 0) call abort()
21 if (msg /= "File 'temptestfile' does not exist") call abort()
23 open(77,file="./", iomsg=msg, iostat=i)
24 if (msg /= "'./' is a directory" .and. msg /= "Invalid argument") call abort()
26 open(77,file=n,status="new")
27 i = chmod(n, "-w")
28 if (i == 0 .and. getuid() /= 0) then
29 close(77, status="keep")
30 open(77,file=n, iomsg=msg, iostat=i, action="write")
31 if (i == 0) call abort()
32 if (msg /= "Permission denied trying to open file 'temptestfile'") call abort()
33 endif
35 i = chmod(n,"+w")
36 open(77,file=n, iomsg=msg, iostat=i, action="read")
37 close(77, status="delete")
38 end