re PR fortran/17678 (USE statement incorrectly initializes allocatable array)
authorPaul Brook <paul@codesourcery.com>
Thu, 7 Oct 2004 00:43:21 +0000 (00:43 +0000)
committerPaul Brook <pbrook@gcc.gnu.org>
Thu, 7 Oct 2004 00:43:21 +0000 (00:43 +0000)
PR fortran/17678
* trans-array.c (gfc_trans_deferred_array): Leave use associated
variables alone.
testsuite/
* gfortran.dg/use_allocated_1.f90: New test.

From-SVN: r88655

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

index 276e5864b8bd627d921f93f7b38d061933494732..60c8dba558a36dc5547be4e18476d2f99b9578ce 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-07  Paul Brook  <paul@codesourcery.com>
+
+       PR fortran/17678
+       * trans-array.c (gfc_trans_deferred_array): Leave use associated
+       variables alone.
+
 2004-10-06  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/17568
index a6397d313fd5d3946004e51a126c3a805ec8decf..d36155dc3641b289a2ce6f6e6b5504e77af01a68 100644 (file)
@@ -3999,8 +3999,8 @@ gfc_trans_deferred_array (gfc_symbol * sym, tree body)
       && !INTEGER_CST_P (sym->ts.cl->backend_decl))
     gfc_trans_init_string_length (sym->ts.cl, &fnblock);
 
-  /* Parameter variables don't need anything special.  */
-  if (sym->attr.dummy)
+  /* Parameter and use associated variables don't need anything special.  */
+  if (sym->attr.dummy || sym->attr.use_assoc)
     {
       gfc_add_expr_to_block (&fnblock, body);
 
index 498f92d51ab87500aab50bcecb5594931365f2aa..04ce16093e7dfed496f4626c7feb94e0cf74db20 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-07  Paul Brook  <paul@codesourcery.com>
+
+       PR fortran/17678
+       * gfortran.dg/use_allocated_1.f90: New test.
+
 2004-10-06  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR middle-end/17849
diff --git a/gcc/testsuite/gfortran.dg/use_allocated_1.f90 b/gcc/testsuite/gfortran.dg/use_allocated_1.f90
new file mode 100644 (file)
index 0000000..fb51502
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do run }
+! PR17678
+! We were incorrectly setting use-associated variables to unallocated
+! on procedure entry.
+module foo
+  integer, dimension(:), allocatable :: bar
+end module
+
+program main
+  use foo
+  allocate (bar(10))
+  call init
+end program main
+
+subroutine init
+  use foo
+  if (.not.allocated(bar)) call abort
+end subroutine init