OSDN Git Service

PR fortran/17678
authorpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 7 Oct 2004 00:43:21 +0000 (00:43 +0000)
committerpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 7 Oct 2004 00:43:21 +0000 (00:43 +0000)
* trans-array.c (gfc_trans_deferred_array): Leave use associated
variables alone.
testsuite/
* gfortran.dg/use_allocated_1.f90: New test.

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

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 276e586..60c8dba 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 a6397d3..d36155d 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 498f92d..04ce160 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