]> git.ipfire.org Git - thirdparty/gcc.git/commit
fortran: ICE using undeclared symbol in array constructor PR93484
authorMark Eggleston <markeggleston@gcc.gnu.org>
Wed, 25 Mar 2020 13:43:23 +0000 (13:43 +0000)
committerMark Eggleston <markeggleston@gcc.gnu.org>
Wed, 25 Mar 2020 13:43:23 +0000 (13:43 +0000)
commitdff885cdc00bbdccb5bb6277e4711093e3bbad1e
treeefbcc31160023d9111b66c499bc4ad5bedb2edde
parent768779dd1165edf49e148bca425321093c7dc15b
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.
gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr93484_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr93484_2.f90 [new file with mode: 0644]