Commit 4c6b3ec7 by Paul Thomas

re PR fortran/30872 (Bogus "size of variable is too large")

2007-04-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30872
	* expr.c (find_array_element): Correct arithmetic for rank > 1.

2007-04-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30872
	* gfortran.dg/parameter_array_element_1.f90: New test.

From-SVN: r123644
parent 909a3e38
2007-04-07 Paul Thomas <pault@gcc.gnu.org> 2007-04-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30872
* expr.c (find_array_element): Correct arithmetic for rank > 1.
2007-04-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31222 PR fortran/31222
* check.c (numeric_check): If an expresson has not got a type, * check.c (numeric_check): If an expresson has not got a type,
see if it is a symbol for which a default type applies. see if it is a symbol for which a default type applies.
......
...@@ -899,6 +899,8 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar, ...@@ -899,6 +899,8 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar,
int i; int i;
mpz_t delta; mpz_t delta;
mpz_t offset; mpz_t offset;
mpz_t span;
mpz_t tmp;
gfc_expr *e; gfc_expr *e;
try t; try t;
...@@ -907,6 +909,8 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar, ...@@ -907,6 +909,8 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar,
mpz_init_set_ui (offset, 0); mpz_init_set_ui (offset, 0);
mpz_init (delta); mpz_init (delta);
mpz_init (tmp);
mpz_init_set_ui (span, 1);
for (i = 0; i < ar->dimen; i++) for (i = 0; i < ar->dimen; i++)
{ {
e = gfc_copy_expr (ar->start[i]); e = gfc_copy_expr (ar->start[i]);
...@@ -930,7 +934,13 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar, ...@@ -930,7 +934,13 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar,
} }
mpz_sub (delta, e->value.integer, ar->as->lower[i]->value.integer); mpz_sub (delta, e->value.integer, ar->as->lower[i]->value.integer);
mpz_mul (delta, delta, span);
mpz_add (offset, offset, delta); mpz_add (offset, offset, delta);
mpz_set_ui (tmp, 1);
mpz_add (tmp, tmp, ar->as->upper[i]->value.integer);
mpz_sub (tmp, tmp, ar->as->lower[i]->value.integer);
mpz_mul (span, span, tmp);
} }
if (cons) if (cons)
...@@ -949,6 +959,8 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar, ...@@ -949,6 +959,8 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar,
depart: depart:
mpz_clear (delta); mpz_clear (delta);
mpz_clear (offset); mpz_clear (offset);
mpz_clear (span);
mpz_clear (tmp);
if (e) if (e)
gfc_free_expr (e); gfc_free_expr (e);
*rval = cons; *rval = cons;
......
2007-04-07 Paul Thomas <pault@gcc.gnu.org> 2007-04-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30872
* gfortran.dg/parameter_array_element_1.f90: New test.
2007-04-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31222 PR fortran/31222
* gfortran.dg/default_numeric_type_1.f90: New test. * gfortran.dg/default_numeric_type_1.f90: New test.
! { dg-do compile}
! { dg-options "-fdump-tree-original" }
! Tests the fix for PR 30872, in which the array element references bo(1,1) etc.
! would be wrong for rank > 1.
!
! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
!
INTEGER, PARAMETER, DIMENSION(2,3) :: bo= &
RESHAPE((/-1,1,-2,2,-3,3/),(/2,3/))
REAL(kind=8), DIMENSION( &
bo(1,1):bo(2,1), &
bo(1,2):bo(2,2), &
bo(1,3):bo(2,3)) :: out_val
out_val=0.0
END
! Scan for the 105 in the declaration real8 out_val[105];
! { dg-final { scan-tree-dump-times "105" 1 "original" } }
! { dg-final { cleanup-tree-dump "original" } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment