2011-08-02 Daniel Kraft <d@domob.eu>
authordomob <domob@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 2 Aug 2011 20:10:13 +0000 (20:10 +0000)
committerdomob <domob@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 2 Aug 2011 20:10:13 +0000 (20:10 +0000)
PR fortran/49885
* trans-array.c (gfc_trans_auto_array_allocation): Change
gfc_start_block to gfc_init_block to avoid spurious extra-scope.

2011-08-02  Daniel Kraft  <d@domob.eu>

PR fortran/49885
* gfortran.dg/auto_char_dummy_array_3.f90: New test.

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

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

index bba8d0f..912c011 100644 (file)
@@ -1,3 +1,9 @@
+2011-08-02  Daniel Kraft  <d@domob.eu>
+
+       PR fortran/49885
+       * trans-array.c (gfc_trans_auto_array_allocation): Change
+       gfc_start_block to gfc_init_block to avoid spurious extra-scope.
+
 2011-08-02  Tobias Burnus  <burnus@net-b.de>
 
        * trans-array.c (gfc_array_allocate): Pass token to
index a151c56..85acf0c 100644 (file)
@@ -4887,7 +4887,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym,
   gcc_assert (GFC_ARRAY_TYPE_P (type));
   onstack = TREE_CODE (type) != POINTER_TYPE;
 
-  gfc_start_block (&init);
+  gfc_init_block (&init);
 
   /* Evaluate character string length.  */
   if (sym->ts.type == BT_CHARACTER
index 7a4dc06..82f2776 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-02  Daniel Kraft  <d@domob.eu>
+
+       PR fortran/49885
+       * gfortran.dg/auto_char_dummy_array_3.f90: New test.
+
 2011-08-02  Kai Tietz  <ktietz@redhat.com>
 
        PR middle-end/49947
diff --git a/gcc/testsuite/gfortran.dg/auto_char_dummy_array_3.f90 b/gcc/testsuite/gfortran.dg/auto_char_dummy_array_3.f90
new file mode 100644 (file)
index 0000000..053956c
--- /dev/null
@@ -0,0 +1,25 @@
+! { dg-do run }
+
+! PR fortran/49885
+! Check that character arrays with non-constant char-length are handled
+! correctly.
+
+! Contributed by Daniel Kraft <d@domob.eu>,
+! based on original test case and variant by Tobias Burnus in comment 2.
+
+PROGRAM main
+  IMPLICIT NONE
+
+  CALL s (10)
+      
+CONTAINS
+
+  SUBROUTINE s (nb)
+    INTEGER :: nb
+    CHARACTER(MAX (80, nb)) :: bad_rec(1)
+
+    bad_rec(1)(1:2) = 'abc'
+    IF (bad_rec(1)(1:2) /= 'ab') CALL abort ()
+  END SUBROUTINE s
+
+END PROGRAM main