[patch, fortran] Fix PR 84697

Thomas Koenig tkoenig@netcologne.de
Tue Mar 6 21:40:00 GMT 2018


Hello world,

the attached patch fixes a bug, partly an 8 regression, for
simplifying an expression containing minloc or maxloc.

The underlying problem was that

     integer, dimension(0), parameter :: z=0

ended up as EXPR_CONSTANT even though the rank was one, which
was then passed to the simplification routines, which either
ICEd or gave wrong results.

In doing this, I had to change the logic of the is_size_zero_array
function. Trying to call it from within the simplification rountines
led to the simplification routines to be called, and so on... until
the stack ran out.

As soon as this is committed, I'll also look if there is anything left
in PR66128, and close that bug if appropriate

Regression-tested. OK for trunk?

2017-03-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/84697
	PR fortran/66128
	* expr.c (simplify_parameter_variable): If p is a size zero array
	and not an ARRAY_EXPR insert an empty array constructor and
	return.
	* gfortran.h: Add prototype for gfc_is_size_zero_array.
	* simplify.c (is_size_zero_array): Make non-static and rename into
	(gfc_is_size_zero_array):  Check for parameter arrays of zero
	size by comparing shape and absence of constructor.
	(gfc_simplify_all): Use gfc_is_size_zero_array instead of
	is_size_zero_array.
	(gfc_simplify_count): Likewise.
	(gfc_simplify_iall): Likewise.
	(gfc_simplify_iany): Likewise.
	(gfc_simplify_iparity): Likewise.
	(gfc_simplify_minval): Likewise.
	(gfc_simplify_maxval): Likewise.
	(gfc_simplify_product): Likewise.
	(gfc_simplify_sum): Likewise.

2017-03-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/84697
	PR fortran/66128
	* gfortran.dg/minmaxloc_zerosize_1.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p3.diff
Type: text/x-patch
Size: 5562 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20180306/70a4c185/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: minmaxloc_zerosize_1.f90
Type: text/x-fortran
Size: 872 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20180306/70a4c185/attachment-0001.bin>


More information about the Fortran mailing list