diff options
author | Mark Eggleston <markeggleston@gcc.gnu.org> | 2020-03-25 08:33:03 +0000 |
---|---|---|
committer | Mark Eggleston <markeggleston@gcc.gnu.org> | 2020-03-25 08:34:50 +0000 |
commit | c38daa7976886a59a3cd496b5c776d75f3cdb056 (patch) | |
tree | 6e2d35208f1e7b5926619c3c086827cabf87cdec /gcc | |
parent | 5f18995e23edc944af3a401d9d9d3320a9362652 (diff) | |
download | gcc-c38daa7976886a59a3cd496b5c776d75f3cdb056.zip gcc-c38daa7976886a59a3cd496b5c776d75f3cdb056.tar.gz gcc-c38daa7976886a59a3cd496b5c776d75f3cdb056.tar.bz2 |
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:
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
PR fortran/93484
* gfortran.dg/pr93484_1.f90: New test.
* gfortran.dg/pr93484_2.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/match.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr93484_1.f90 | 8 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr93484_2.f90 | 8 |
5 files changed, 30 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0591579..0f6dab3 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2020-03-25 Steven G. Kargl <kargl@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-03-23 Mark Eggleston <mark.eggleston@codethink.com> Steven G. Kargl <kargl@gcc.gnu.org> diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 3a0c097..8443d20 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -2248,9 +2248,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 b68779f..4711a09 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-03-25 Mark Eggleston <mark.eggleston@codethink.com> + + PR fortran/93484 + * gfortran.dg/pr93484_1.f90: New test. + * gfortran.dg/pr93484_2.f90: New test. + 2020-03-25 Jakub Jelinek <jakub@redhat.com> PR middle-end/94303 diff --git a/gcc/testsuite/gfortran.dg/pr93484_1.f90 b/gcc/testsuite/gfortran.dg/pr93484_1.f90 new file mode 100644 index 0000000..3b6dbc9 --- /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 0000000..4a7f433 --- /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 + |