re PR fortran/28224 (gfortran should support namelist (nml) for internal file units)
authorTobias Burnus <burnus@net-b.de>
Sat, 28 Oct 2006 21:59:20 +0000 (23:59 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Sat, 28 Oct 2006 21:59:20 +0000 (23:59 +0200)
fortran/
2006-10-28  Tobias Burnus  <burnus@net-b.de>

PR fortran/28224
* io.c (check_io_constraints): Allow namelists
  for internal files for Fortran 2003.

testsuite/
2006-10-28  Tobias Burnus  <burnus@net-b.de>

PR fortran/28224
* gfortran.dg/io_constraints_2.f90: Use -std=f95.
* gfortran.dg/namelist_internal.f90: New test.

From-SVN: r118113

gcc/fortran/ChangeLog
gcc/fortran/io.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/io_constraints_2.f90
gcc/testsuite/gfortran.dg/namelist_internal.f90 [new file with mode: 0644]

index 8ff4a5fff5649ec82aa17eb9402bebab003e3a7c..e5540e026a60ca996dae1859314f8321e8c54ffd 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-28  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/28224
+       * io.c (check_io_constraints): Allow namelists
+         for internal files for Fortran 2003.
+
 2006-10-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/27954
index d4897694bbdc07020ab61001d69ac58cbd978cfd..cbb7cf90b062b4d42057bc83b83ab13b01c4fe4d 100644 (file)
@@ -2596,9 +2596,13 @@ if (condition) \
                     "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 e93c33825a2c5c67a9f8714b7d3db1f4aa6c78a6..ca0f3127fd5235b5b0bbde7d5b9545402aa15e3b 100644 (file)
@@ -1,4 +1,10 @@
-2006-10-28 Tobias Burnus <burnus@net-b.de>
+2006-10-28  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/28224 
+       * gfortran.dg/io_constraints_2.f90: Use -std=f95.
+       * gfortran.dg/namelist_internal.f90: New test. 
+
+2006-10-28  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/29625
        * gfortran.dg/io_real_boz.f90: Add.
index c2a49e29d16d8b051ad12acad4a10ad94004626a..0b2c2049adfa215102c9cb7997ee05336a397b69 100644 (file)
@@ -1,4 +1,5 @@
 ! { dg-do compile }
+! { dg-options "-std=f95" }
 ! Part II of the test  of the IO constraints patch, which fixes PRs:
 ! PRs 25053, 25063, 25064, 25066, 25067, 25068, 25069, 25307 and 20862.
 ! Modified2006-07-08 to check the patch for PR20844.
@@ -35,7 +36,7 @@ end module global
 
  write(*, NML=NL) z                             !  { dg-error "followed by IO-list" }
 !Was correctly picked up before patch.
- print NL, z                                    !  { dg-error "followed by IO-list" }
+ print NL, z                                    !  { dg-error "PRINT namelist at \\(1\\) is an extension" }
 !
 ! Not allowed with internal unit
 !Was correctly picked up before patch.
diff --git a/gcc/testsuite/gfortran.dg/namelist_internal.f90 b/gcc/testsuite/gfortran.dg/namelist_internal.f90
new file mode 100644 (file)
index 0000000..4f8aeb2
--- /dev/null
@@ -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