re PR fortran/29060 (spread causes ICE in gfc_trans_array_constructor)

2006-09-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29060
	* iresolve.c (resolve_spread): Build shape for result if the
	source shape is available and dim and ncopies are constants.

	PR fortran/28817
	PR fortran/21918
	* trans-decl.c (generate_local_decl): Change from 'warning' to
	'gfc_warning' to have line numbers correctly reported.

2006-09-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29060
	* gfortran.dg/spread_shape_1.f90: New test.

From-SVN: r117014
This commit is contained in:
Paul Thomas 2006-09-18 06:24:54 +00:00
parent 9adc3dc789
commit 80f2bb6e3a
5 changed files with 59 additions and 2 deletions

View File

@ -1,3 +1,16 @@
2006-09-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29060
* iresolve.c (resolve_spread): Build shape for result if the
source shape is available and dim and ncopies are constants.
2006-09-18 Tobias Schl<68>üter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/28817
PR fortran/21918
* trans-decl.c (generate_local_decl): Change from 'warning' to
'gfc_warning' to have line numbers correctly reported.
2006-09-15 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29051

View File

@ -1885,6 +1885,23 @@ gfc_resolve_spread (gfc_expr * f, gfc_expr * source,
? PREFIX("spread_char")
: PREFIX("spread"));
if (dim && gfc_is_constant_expr (dim)
&& ncopies && gfc_is_constant_expr (ncopies)
&& source->shape[0])
{
int i, idim;
idim = mpz_get_ui (dim->value.integer);
f->shape = gfc_get_shape (f->rank);
for (i = 0; i < (idim - 1); i++)
mpz_init_set (f->shape[i], source->shape[i]);
mpz_init_set (f->shape[idim - 1], ncopies->value.integer);
for (i = idim; i < f->rank ; i++)
mpz_init_set (f->shape[i], source->shape[i-1]);
}
gfc_resolve_dim_arg (dim);
gfc_resolve_index (ncopies, 1);
}

View File

@ -2883,12 +2883,14 @@ generate_local_decl (gfc_symbol * sym)
if (sym->attr.referenced)
gfc_get_symbol_decl (sym);
else if (sym->attr.dummy && warn_unused_parameter)
warning (0, "unused parameter %qs", sym->name);
gfc_warning ("Unused parameter %s declared at %L", sym->name,
&sym->declared_at);
/* Warn for unused variables, but not if they're inside a common
block or are use-associated. */
else if (warn_unused_variable
&& !(sym->attr.in_common || sym->attr.use_assoc))
warning (0, "unused variable %qs", sym->name);
gfc_warning ("Unused variable %s declared at %L", sym->name,
&sym->declared_at);
/* For variable length CHARACTER parameters, the PARM_DECL already
references the length variable, so force gfc_get_symbol_decl
even when not referenced. If optimize > 0, it will be optimized

View File

@ -1,3 +1,8 @@
2006-09-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29060
* gfortran.dg/spread_shape_1.f90: New test.
2006-09-17 Roger Sayle <roger@eyesopen.com>
PR tree-optimization/28887

View File

@ -0,0 +1,20 @@
! { dg-do compile }
! Tests the fix for PR29060 in which the shape of the result
! of SPREAD was not available to the scalarizer.
!
! Contributed by Paul Thomas <pault@gcc.gnu.org>
real,dimension(:, :),pointer :: ptr
real,dimension(2, 2),parameter :: u = &
reshape((/0.25, 0.5, 0.75, 1.00/),(/2,2/))
allocate (ptr(2,2))
! Original PR
ptr(:, :) = u + spread ((/1.0, 2.0/), 2, size(u, 2))
if (any (ptr .ne. &
reshape ((/1.25, 2.50, 1.75, 3.00/), (/2, 2/)))) call abort ()
! Check that the fix works correctly with the source shape after ncopies
ptr(:, :) = u + spread ((/2.0, 3.0/), 1, size (u, 1))
if (any (ptr .ne. &
reshape ((/2.25, 2.50, 3.75, 4.00/), (/2,2/)))) call abort ()
end