This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch,fortran] Allow namelist with internal file (PR 28224)
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Thu, 26 Oct 2006 09:40:38 +0200
- Subject: [patch,fortran] Allow namelist with internal file (PR 28224)
:ADDPATCH fortran:
Hello,
This patch implements read/write of namelists from/to internal
files, which is allowed in Fortran 2003 but not in Fortran 95.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28224
Bootstrapped and regression tested on x86_64-unknown-linux-gnu (4.3.0
20061026).
Tobias
2006-10-26 Tobias Burnus <burnus@net-b.de>
PR fortran/28224
* io.c (check_io_constraints): Allow namelists
for internal files for Fortran 2003.
2006-10-26 Tobias Burnus <burnus@net-b.de>
PR fortran/PR28224
* gfortran.dg/io_constraints_2.f90: Remove check for
using namelists with internal files.
* gfortran.dg/namelist_internal.f90: New namelist test.
* gfortran.dg/namelist_internal2.f90: New namelist test.
This patch implements read/write of namelists from/to internal
files, which is allowed in Fortran 2003 but not in Fortran 95.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28224
Regression tested on x86_64-unknown-linux-gnu (4.3.0 20061025).
Tobias
PS: I seem to have a fixed glibc as I get:
XPASS: gfortran.dg/csqrt_2.f (PR24313).
How is this XPASS expected to be used?
2006-10-26 Tobias Burnus <burnus@net-b.de>
PR fortran/28224
* io.c (check_io_constraints): Allow namelists
for internal files for Fortran 2003.
2006-10-26 Tobias Burnus <burnus@net-b.de>
PR fortran/PR28224
* gfortran.dg/io_constraints_2.f90: Remove check for
using namelists with internal files.
* gfortran.dg/namelist_internal.f90: New namelists test.
* gfortran.dg/namelist_internal2.f90: New namelists test.
Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c (Revision 118044)
+++ gcc/fortran/io.c (Arbeitskopie)
@@ -2596,9 +2596,13 @@
"REC tag at %L is incompatible with internal file",
&dt->rec->where);
- io_constraint (dt->namelist != NULL,
- "Internal file at %L is incompatible with namelist",
- &expr->where);
+ if (dt->namelist != NULL)
+ {
+ if (gfc_notify_std(GFC_STD_F2003,
+ "Internal file at %L is incompatible with namelist",
+ &expr->where) == FAILURE)
+ m = MATCH_ERROR;
+ }
io_constraint (dt->advance != NULL,
"ADVANCE tag at %L is incompatible with internal file",
Index: gcc/testsuite/gfortran.dg/io_constraints_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/io_constraints_2.f90 (Revision 118044)
+++ gcc/testsuite/gfortran.dg/io_constraints_2.f90 (Arbeitskopie)
@@ -39,8 +39,6 @@
!
! Not allowed with internal unit
!Was correctly picked up before patch.
- write(buffer, NML=NL) ! { dg-error "incompatible with namelist" }
-!Was correctly picked up before patch.
write(buffer, fmt='(i6)', REC=10) a ! { dg-error "REC tag" }
write(buffer, fmt='(i6)', END=10) a ! { dg-error "END tag" }
--- /dev/null 2006-10-15 18:34:35.000000000 +0200
+++ gcc/testsuite/gfortran.dg/namelist_internal.f90 2006-10-26 01:00:42.000000000 +0200
@@ -0,0 +1,21 @@
+! { dg-do run }
+! { dg-options "-fall-intrinsics -std=f2003" }
+! Checks internal file read/write of namelists
+! (Fortran 2003 feature)
+! PR fortran/28224
+program nml_internal
+ integer :: i, j
+ real :: r
+ namelist /nam/ i, j, r
+ character(len=250) :: str
+
+ i = 42
+ j = -718
+ r = exp(1.0)
+ write(str,nml=nam)
+ i = -33
+ j = 10
+ r = sin(1.0)
+ read(str,nml=nam)
+ if(i /= 42 .or. j /= -718 .or. abs(r-exp(1.0)) > 1e-5) call abort()
+end program nml_internal
--- /dev/null 2006-10-15 18:34:35.000000000 +0200
+++ gcc/testsuite/gfortran.dg/namelist_internal2.f90 2006-10-26 01:00:40.000000000 +0200
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options "-fall-intrinsics -std=f95" }
+! Checks internal file read/write of namelists
+! (Fortran 2003 feature)
+! PR fortran/28224
+program nml_internal
+ implicit none
+ integer :: i, j
+ real :: r
+ namelist /nam/ i, j, r
+ character(len=250) :: str
+
+ i = 42
+ j = -718
+ r = exp(1.0)
+ write(str,nml=nam) ! { dg-error "Internal file at (1) is incompatible with namelist"}
+ i = -33
+ j = 10
+ r = sin(1.0)
+ read(str,nml=nam) ! { dg-error "Internal file at (1) is incompatible with namelist"}
+ if(i /= 42 .or. j /= -718 .or. abs(r-exp(1.0)) > 1e-5) call abort()
+end program nml_internal