OSDN Git Service

2006-09-18 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Sep 2006 06:24:54 +0000 (06:24 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Sep 2006 06:24:54 +0000 (06:24 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117014 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/iresolve.c
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/spread_shape_1.f90 [new file with mode: 0644]

index bf2c58d..04b8c8e 100644 (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\81ü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
index a9a9858..c72bf9f 100644 (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);
 }
index 855c982..e4c5a5a 100644 (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
index ee17e19..3311a54 100644 (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
diff --git a/gcc/testsuite/gfortran.dg/spread_shape_1.f90 b/gcc/testsuite/gfortran.dg/spread_shape_1.f90
new file mode 100644 (file)
index 0000000..c9f96f3
--- /dev/null
@@ -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