aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2006-09-18 06:24:54 +0000
committerPaul Thomas <pault@gcc.gnu.org>2006-09-18 06:24:54 +0000
commit80f2bb6e3af5a9ae2576f86258cdafa7fe1ff384 (patch)
tree795e77314928c5d566f1e60e6c2032bc761cf1e5 /gcc
parent9adc3dc789b21d98f700141801cafec29489d92c (diff)
downloadgcc-80f2bb6e3af5a9ae2576f86258cdafa7fe1ff384.zip
gcc-80f2bb6e3af5a9ae2576f86258cdafa7fe1ff384.tar.gz
gcc-80f2bb6e3af5a9ae2576f86258cdafa7fe1ff384.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog13
-rw-r--r--gcc/fortran/iresolve.c17
-rw-r--r--gcc/fortran/trans-decl.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/spread_shape_1.f9020
5 files changed, 59 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index bf2c58d..04b8c8e 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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ü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
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index a9a9858..c72bf9f 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -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);
}
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 855c982..e4c5a5a 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ee17e19..3311a54 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/spread_shape_1.f90 b/gcc/testsuite/gfortran.dg/spread_shape_1.f90
new file mode 100644
index 0000000..c9f96f3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/spread_shape_1.f90
@@ -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