public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jerry DeLisle <jvdelisle@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-9048] libgfortran: Fix namelist read.
Date: Sat, 17 Feb 2024 15:35:21 +0000 (GMT)	[thread overview]
Message-ID: <20240217153521.24F49385DC2B@sourceware.org> (raw)

https://gcc.gnu.org/g:fccfe6625121512f247cb59888e50eb9dcc84409

commit r14-9048-gfccfe6625121512f247cb59888e50eb9dcc84409
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date:   Fri Feb 16 17:06:37 2024 -0800

    libgfortran: Fix namelist read.
    
            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.

Diff:
---
 gcc/testsuite/gfortran.dg/pr107068.f90 | 22 ++++++++++++++++++++++
 libgfortran/io/list_read.c             |  8 ++++++++
 2 files changed, 30 insertions(+)

diff --git a/gcc/testsuite/gfortran.dg/pr107068.f90 b/gcc/testsuite/gfortran.dg/pr107068.f90
new file mode 100644
index 000000000000..c5ea0c1d2446
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr107068.f90
@@ -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
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index f8ca64422de5..0b7884fdda7f 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -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.  */

                 reply	other threads:[~2024-02-17 15:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240217153521.24F49385DC2B@sourceware.org \
    --to=jvdelisle@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).