re PR fortran/47421 (Wrong-code: Value of scalar ALLOCATABLE CHARACTER(len=n) dummy...
authorTobias Burnus <burnus@net-b.de>
Sun, 23 Jan 2011 22:26:27 +0000 (23:26 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Sun, 23 Jan 2011 22:26:27 +0000 (23:26 +0100)
2011-01-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47421
        * trans-decl.c (gfc_trans_deferred_vars): Do not nullify
        scalar allocatable dummy arguments.

2011-01-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47421
        * gfortran.dg/allocatable_scalar_12.f90: New.

From-SVN: r169145

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

index e918ef5b9294ee7092f839d29fdbbe21dec5c3c0..489cacad2912d5a06a70d59aa395ab98dbdcb60c 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-23  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/47421
+       * trans-decl.c (gfc_trans_deferred_vars): Do not nullify
+       scalar allocatable dummy arguments.
+
 2011-01-22  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/38536
index 254db76b0c5084a6b99a3a6464d45b8e03a0916a..5e3afbe8219d0e4ec93d9c0d90a955ed14bee47c 100644 (file)
@@ -3304,9 +3304,10 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
          if (sym_has_alloc_comp && !seen_trans_deferred_array)
            gfc_trans_deferred_array (sym, block);
        }
-      else if (sym->attr.allocatable
-              || (sym->ts.type == BT_CLASS
-                  && CLASS_DATA (sym)->attr.allocatable))
+      else if (!sym->attr.dummy
+               && (sym->attr.allocatable
+                   || (sym->ts.type == BT_CLASS
+                       && CLASS_DATA (sym)->attr.allocatable)))
        {
          if (!sym->attr.save)
            {
index c4cc1e089277c34bc890109bcc81fc8097a53b75..71825be5ae68a51a4499041a6c308c96bc67fa7a 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-23  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/47421
+       * gfortran.dg/allocatable_scalar_12.f90: New.
+
 2011-01-23  Ira Rosen  <irar@il.ibm.com>
 
        * gcc.dg/vect/costmodel/spu/costmodel-vect-33.c: Expect
diff --git a/gcc/testsuite/gfortran.dg/allocatable_scalar_12.f90 b/gcc/testsuite/gfortran.dg/allocatable_scalar_12.f90
new file mode 100644 (file)
index 0000000..eade363
--- /dev/null
@@ -0,0 +1,30 @@
+! { dg-do run }
+!
+! PR fortran/47421
+!
+! Don't auto-deallocatable scalar character allocatables.
+!
+implicit none
+character(len=5), allocatable :: str
+allocate(str)
+str = '1bcde'
+if(str /= '1bcde') call abort()
+call sub(str,len(str))
+if(str /= '1bcde') call abort()
+call subOUT(str,len(str))
+if (len(str) /= 5) call abort()
+if(allocated(str)) call abort()
+contains
+  subroutine sub(x,n)
+     integer :: n
+     character(len=n), allocatable :: x
+     if(len(x) /= 5) call abort()
+     if(x /= '1bcde') call abort()
+  end subroutine sub
+  subroutine subOUT(x,n)
+     integer :: n
+     character(len=n), allocatable,intent(out) :: x
+     if(allocated(x)) call abort()
+     if(len(x) /= 5) call abort()
+  end subroutine subOUT
+end