This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR16206 - array initializers
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Paul Thomas <paulthomas2 at wanadoo dot fr>
- Cc: patch <gcc-patches at gcc dot gnu dot org>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Sat, 17 Jun 2006 20:40:04 -0700
- Subject: Re: [Patch, fortran] PR16206 - array initializers
- References: <44938BAC.1070900@wanadoo.fr>
On Sat, Jun 17, 2006 at 06:57:16AM +0200, Paul Thomas wrote:
> 2006-06-17 Paul Thomas <pault@gcc.gnu.org>
>
> PR fortran/16206
> * expr.c (find_array_element): Eliminate condition on length of
> offset. Add bounds checking. Rearrange exit. Return try and
> put gfc_constructor result as an argument.
> (find_array_section): New function.
> (find_substring_ref): New function.
> (simplify_const_ref): Add calls to previous.
> (gfc_simplify_expr): Only call gfc_expand_constructor for full
> arrays.
>
> 2006-06-17 Paul Thomas <pault@gcc.gnu.org>
>
> PR fortran/16206
> * gfortran.dg/array_initializer_1.f90: New test.
>
>
There a few minor questions/details to consider see below.
!
! /* Check the bounds. */
! if (ar->as->upper[i]
! && (mpz_cmp (e->value.integer,
! ar->as->upper[i]->value.integer) > 0
! || mpz_cmp (e->value.integer,
! ar->as->upper[i]->value.integer) > 0
These mpz_cmp appear to be redundant.
! || mpz_cmp (e->value.integer,
! ar->as->lower[i]->value.integer) < 0
! || mpz_cmp (e->value.integer,
! ar->as->lower[i]->value.integer) < 0))
These mpz_cmp appear to be redundant.
*************** remove_subobject_ref (gfc_expr * p, gfc_
*** 985,990 ****
--- 1008,1225 ----
}
+ if (expr->shape == NULL)
+ expr->shape = gfc_get_shape (rank);
+
+ mpz_init_set_ui (delta_mpz, one);
+ mpz_init_set_ui (nelts, one);
+ mpz_init (tmp_mpz);
+
+ /* Build the counters to clock through the array reference. */
+ for (idx = 0; idx < rank; idx++)
+ {
+ /* Make this stretch of code easier on the eye! */
+ begin = ref->u.ar.start[idx];
+ finish = ref->u.ar.end[idx];
+ step = ref->u.ar.stride[idx];
+ lower = ref->u.ar.as->lower[idx];
+ upper = ref->u.ar.as->upper[idx];
+
+ if ((begin && begin->expr_type != EXPR_CONSTANT)
+ || (finish && finish->expr_type != EXPR_CONSTANT)
+ || (step && step->expr_type != EXPR_CONSTANT))
+ return FAILURE;
Doesn't this "return FAILURE" leak memory? Should you free at least the
mpz variables?
+ {
+ gfc_error ("index in dimension %d is out of bounds "
+ "at %L", idx + 1, &ref->u.ar.c_where[idx]);
+ return FAILURE;
Again, is memory leaked here?
--
Steve