re PR fortran/36257 (SPREAD gives wrong results with array CHARACTER parameters)
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 21 May 2008 16:01:08 +0000 (16:01 +0000)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 21 May 2008 16:01:08 +0000 (16:01 +0000)
PR fortran/36257

* gfortran.dg/char_length_12.f90: New test.

* iresolve.c (check_charlen_present): Don't force the rank to 1.

From-SVN: r135723

gcc/fortran/ChangeLog
gcc/fortran/iresolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/char_length_12.f90 [new file with mode: 0644]

index 436142879dab18c08137cbb2262aec3bc1bb3eb9..0161a2a79c90d417fd59aed8d8167be7440acb3e 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-21  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/36257
+       * iresolve.c (check_charlen_present): Don't force the rank to 1.
+
 2008-05-19  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/36265
index 4b7e17d70f3894e94ac7998753ddb9be3703231c..94ed4a67bafac0baa9b8e0de4b6e85f2bb9f1fdd 100644 (file)
@@ -75,11 +75,8 @@ check_charlen_present (gfc_expr *source)
       source->rank = 0;
     }
   else if (source->expr_type == EXPR_ARRAY)
-    {
-      source->ts.cl->length =
+    source->ts.cl->length =
        gfc_int_expr (source->value.constructor->expr->value.character.length);
-      source->rank = 1;
-    }
 }
 
 /* Helper function for resolving the "mask" argument.  */
index 0267b43ff9ebf0487c72d559672b06c8e4275fd5..e2e4323a99a8567e383c18682b2b5b7f677086c1 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-21  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/36257
+       * gfortran.dg/char_length_12.f90: New test.
+
 2008-05-20  Nathan Sidwell  <nathan@codesourcery.com>
 
        * gcc.c-torture/execute/builtins/memops-asm.c: Set inside_main.
diff --git a/gcc/testsuite/gfortran.dg/char_length_12.f90 b/gcc/testsuite/gfortran.dg/char_length_12.f90
new file mode 100644 (file)
index 0000000..f22eb6c
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do run }
+
+  implicit none
+  character(len=3), dimension(3,3), parameter :: &
+    p = reshape(["xyz", "abc", "mkl", "vpn", "lsd", "epo", "tgv", &
+                 "bbc", "wto"], [3,3])
+  character(len=3), dimension(3,3) :: m1
+
+  m1 = p
+  if (any (spread (p, 1, 2) /= spread (m1, 1, 2))) call abort
+
+end