* [patch, fortran] Fix PR 85111, some more zero size stuff
@ 2018-03-29 18:07 Thomas Koenig
2018-03-30 2:31 ` Jerry DeLisle
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Koenig @ 2018-03-29 18:07 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
Hello world,
the attached patch fixes PR 85111, a regression introduced with my
recent simplification patches. Seems like the zero-size saga
has yet another chapter :-)
Regression-tested. OK for trunk?
Regards
Thomas
2017-03-29 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/85111
* array.c (gfc_resolve_character_array_constructor): Early
exit for zero-size arrays.
* simplify.c (simplify_transformation_to_array): Exit early
if the result size is zero.
(simplify_minmaxloc_to_array): Likewise.
2017-03-29 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/85111
* gfortran.dg/zero_sized_10.f90: New test.
[-- Attachment #2: p1.diff --]
[-- Type: text/x-patch, Size: 1113 bytes --]
Index: array.c
===================================================================
--- array.c (revision 258845)
+++ array.c (working copy)
@@ -2003,6 +2003,20 @@ gfc_resolve_character_array_constructor (gfc_expr
got_charlen:
+ /* Early exit for zero size arrays. */
+ if (expr->shape)
+ {
+ mpz_t size;
+ HOST_WIDE_INT arraysize;
+
+ gfc_array_size (expr, &size);
+ arraysize = mpz_get_ui (size);
+ mpz_clear (size);
+
+ if (arraysize == 0)
+ return true;
+ }
+
found_length = -1;
if (expr->ts.u.cl->length == NULL)
Index: simplify.c
===================================================================
--- simplify.c (revision 258845)
+++ simplify.c (working copy)
@@ -627,7 +627,7 @@ simplify_transformation_to_array (gfc_expr *result
n += 1;
}
- done = false;
+ done = resultsize <= 0;
base = arrayvec;
dest = resultvec;
while (!done)
@@ -5304,7 +5304,7 @@ simplify_minmaxloc_to_array (gfc_expr *result, gfc
n += 1;
}
- done = false;
+ done = resultsize <= 0;
base = arrayvec;
dest = resultvec;
while (!done)
[-- Attachment #3: zero_sized_10.f90 --]
[-- Type: text/x-fortran, Size: 511 bytes --]
! { dg-do compile }
! { PR 85111 - this used to ICE. }
! Original test case by Gernhard Steinmetz.
program p
integer, parameter :: a(2,0) = reshape([1,2,3,4], shape(a))
character, parameter :: ac(2,0) = reshape(['a','b','c','d'], shape(ac))
integer, parameter :: b(2) = maxloc(a, dim=1) ! { dg-error "Different shape" }
integer, parameter :: c(2) = minloc(a, dim=1) ! { dg-error "Different shape" }
character, parameter :: d(2) = maxval(ac, dim=1) ! { dg-error "Different shape" }
end program p
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch, fortran] Fix PR 85111, some more zero size stuff
2018-03-29 18:07 [patch, fortran] Fix PR 85111, some more zero size stuff Thomas Koenig
@ 2018-03-30 2:31 ` Jerry DeLisle
0 siblings, 0 replies; 2+ messages in thread
From: Jerry DeLisle @ 2018-03-30 2:31 UTC (permalink / raw)
To: Thomas Koenig, fortran, gcc-patches
On 03/29/2018 11:07 AM, Thomas Koenig wrote:
> Hello world,
>
> the attached patch fixes PR 85111, a regression introduced with my
> recent simplification patches. Seems like the zero-size saga
> has yet another chapter :-)
>
> Regression-tested. OK for trunk?
>
Looks OK,
Thanks,
Jerry
> Regards
>
> Â Â Â Â Thomas
>
> 2017-03-29 Thomas Koenig <tkoenig@gcc.gnu.org>
>
> Â Â Â Â Â Â Â PR fortran/85111
> Â Â Â Â Â Â Â * array.c (gfc_resolve_character_array_constructor): Early
> Â Â Â Â Â Â Â exit for zero-size arrays.
> Â Â Â Â Â Â Â * simplify.c (simplify_transformation_to_array): Exit early
> Â Â Â Â Â Â Â if the result size is zero.
> Â Â Â Â Â Â Â (simplify_minmaxloc_to_array): Likewise.
>
> 2017-03-29 Thomas Koenig <tkoenig@gcc.gnu.org>
>
> Â Â Â Â Â Â Â PR fortran/85111
> Â Â Â Â Â Â Â * gfortran.dg/zero_sized_10.f90: New test.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-30 2:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-29 18:07 [patch, fortran] Fix PR 85111, some more zero size stuff Thomas Koenig
2018-03-30 2:31 ` Jerry DeLisle
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).