]> gcc.gnu.org Git - gcc.git/commitdiff
libgfortran: Fix namelist read.
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Sat, 17 Feb 2024 01:06:37 +0000 (17:06 -0800)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Sat, 17 Feb 2024 15:34:12 +0000 (07:34 -0800)
PR libfortran/107068

libgfortran/ChangeLog:

* io/list_read.c (read_logical): When looking for a possible
variable name, check for left paren, indicating a possible
array reference.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr107068.f90: New test.

gcc/testsuite/gfortran.dg/pr107068.f90 [new file with mode: 0644]
libgfortran/io/list_read.c

diff --git a/gcc/testsuite/gfortran.dg/pr107068.f90 b/gcc/testsuite/gfortran.dg/pr107068.f90
new file mode 100644 (file)
index 0000000..c5ea0c1
--- /dev/null
@@ -0,0 +1,22 @@
+! { dg-do run }
+program test
+  implicit none
+  integer :: error
+  logical, dimension(3,3) :: flc,flp
+  namelist/inputdata/flc, flp
+
+  flc = .false.
+  flp = .false.
+
+  open(10, file="inputfile")
+  write(10,*) "&INPUTDATA"
+  write(10,*) " FLC = T, "
+  write(10,*) " FLP(1,2) = T,"
+  write(10,*) "/"
+  rewind(10)
+  !write(*, nml=inputdata)
+  !open(10,file="inputfile")
+  read(10,inputdata,iostat=error)
+  close(10, status='delete')
+  if (error /= 0) stop 20
+end program test
index f8ca64422de57358435998898fe2ff87c3945909..0b7884fdda7ff557899644e83cff028526ccefcd 100644 (file)
@@ -888,6 +888,14 @@ read_logical (st_parameter_dt *dtp, int length)
   for(i = 0; i < 63; i++)
     {
       c = next_char (dtp);
+      if (c == '(')
+       {
+         l_push_char (dtp, c);
+         dtp->u.p.nml_read_error = 1;
+         dtp->u.p.line_buffer_enabled = 1;
+         dtp->u.p.line_buffer_pos = 0;
+         return;
+       }
       if (is_separator(c))
        {
          /* All done if this is not a namelist read.  */
This page took 0.087058 seconds and 5 git commands to generate.