public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] fortran: ICE using undeclared symbol in array constructor PR93484
Date: Thu, 17 Sep 2020 16:52:45 +0000 (GMT)	[thread overview]
Message-ID: <20200917165245.423F6398D020@sourceware.org> (raw)

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

commit a60e16f2c28ed853da109e9266243c388a6a512f
Author: Mark Eggleston <markeggleston@gcc.gnu.org>
Date:   Wed Mar 25 15:10:03 2020 +0000

    fortran: ICE using undeclared symbol in array constructor PR93484
    
    Using undeclared symbol k in an expression in the following
    array constructor results in an ICE:
    
        print *, [real(x(k))]
    
    If the call to the intrinsic is not in a constructor a no IMPLICIT
    type error is reported and the ICE does not occur.
    
    Matching on an expression instead of an initialisation express an
    and not converting a MATCH_ERROR return value into MATCH_NO results
    in the no IMPLICIT error and no ICE.
    
    Note: Steven G. Kargl  <kargl@gcc.gnu.org> is the author of the
    changes except for the test cases.
    
    gcc/fortran/ChangeLog:
    
            Backport from master
            2020-03-25  Mark Eggleston <markeggleston@gcc.gnu.org>
    
            PR fortran/93484
            * match.c (gfc_match_type_spec): Replace gfc_match_init_expr with
            gfc_match_expr. Return m if m is MATCH_NO or MATCH_ERROR.
    
    gcc/testsuite
    
            Backport from master
            2020-03-25  Mark Eggleston <markeggleston@gcc.gnu.org>
    
            PR fortran/93484
            * gfortran.dg/pr93484_1.f90: New test.
            * gfortran.dg/pr93484_2.f90: New test.

Diff:
---
 gcc/fortran/ChangeLog                   | 9 +++++++++
 gcc/fortran/match.c                     | 4 ++--
 gcc/testsuite/ChangeLog                 | 9 +++++++++
 gcc/testsuite/gfortran.dg/pr93484_1.f90 | 8 ++++++++
 gcc/testsuite/gfortran.dg/pr93484_2.f90 | 8 ++++++++
 5 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index d078dfb7533..012286a1c72 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2020-03-25  Mark Eggleston <markeggleston@gcc.gnu.org>
+
+	Backport from master
+	2020-03-25  Mark Eggleston <markeggleston@gcc.gnu.org>
+
+	PR fortran/93484
+	* match.c (gfc_match_type_spec): Replace gfc_match_init_expr with
+	gfc_match_expr. Return m if m is MATCH_NO or MATCH_ERROR.
+
 2020-02-04  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from mainline
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index d0a4b53da6b..9b61f1f52ec 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -2183,9 +2183,9 @@ gfc_match_type_spec (gfc_typespec *ts)
 
 found:
 
-      m = gfc_match_init_expr (&e);
+      m = gfc_match_expr (&e);
       if (m == MATCH_NO || m == MATCH_ERROR)
-	return MATCH_NO;
+	return m;
 
       /* If a comma appears, it is an intrinsic subprogram. */
       gfc_gobble_whitespace ();
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6b8ae682501..fafcd9ed4db 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2020-03-25  Mark Eggleston <markeggleston@gcc.gnu.org>
+
+	Backport from master
+	2020-03-25  Mark Eggleston <markeggleston@gcc.gnu.org>
+
+	PR fortran/93484
+	* gfortran.dg/pr93484_1.f90: New test.
+	* gfortran.dg/pr93484_2.f90: New test.
+
 2020-03-24  Tamar Christina  <tamar.christina@arm.com>
 
 	* g++.target/aarch64/aarch64.exp: New file.
diff --git a/gcc/testsuite/gfortran.dg/pr93484_1.f90 b/gcc/testsuite/gfortran.dg/pr93484_1.f90
new file mode 100644
index 00000000000..3b6dbc9ad79
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93484_1.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+!
+program p
+  implicit none
+  integer :: x(4) = [1,2,3,4]
+  print *, [real(x(k))] ! { dg-error "Symbol 'k' at .1. has no IMPLICIT type" } 
+end
+
diff --git a/gcc/testsuite/gfortran.dg/pr93484_2.f90 b/gcc/testsuite/gfortran.dg/pr93484_2.f90
new file mode 100644
index 00000000000..4a7f4330ed9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93484_2.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+!
+program p
+  implicit none
+  integer, parameter :: x(4) = [1,2,3,4]
+  print *, [real(x(k))] ! { dg-error "Symbol 'k' at .1. has no IMPLICIT type" }
+end
+


                 reply	other threads:[~2020-09-17 16:52 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=20200917165245.423F6398D020@sourceware.org \
    --to=jakub@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).