OSDN Git Service

2010-01-05 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Jan 2010 07:19:30 +0000 (07:19 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Jan 2010 07:19:30 +0000 (07:19 +0000)
        PR fortran/41872
        * trans-expr.c (gfc_conv_procedure_call): Nullify
        return value for allocatable-scalar character functions.

2010-01-05  Tobias Burnus  <burnus@net-b.de>

        PR fortran/41872
        * gfortran.dg/allocatable_scalar_8.f90: New.

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

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

index 1e6501a..6a59425 100644 (file)
@@ -1,3 +1,9 @@
+2010-01-05  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/41872
+       * trans-expr.c (gfc_conv_procedure_call): Nullify
+       return value for allocatable-scalar character functions.
+
 2010-01-04  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/36161
index 84eb585..e5fce02 100644 (file)
@@ -3351,6 +3351,12 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
            {
              var = gfc_create_var (type, "pstr");
 
+             if ((!comp && sym->attr.allocatable)
+                 || (comp && comp->attr.allocatable))
+               gfc_add_modify (&se->pre, var,
+                               fold_convert (TREE_TYPE (var),
+                                             null_pointer_node));
+
              /* Provide an address expression for the function arguments.  */
              var = gfc_build_addr_expr (NULL_TREE, var);
            }
index 603f629..08622cb 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-05  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/41872
+       * gfortran.dg/allocatable_scalar_8.f90: New.
+
 2010-01-04  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/42398
diff --git a/gcc/testsuite/gfortran.dg/allocatable_scalar_8.f90 b/gcc/testsuite/gfortran.dg/allocatable_scalar_8.f90
new file mode 100644 (file)
index 0000000..f7940ed
--- /dev/null
@@ -0,0 +1,17 @@
+! { dg-do run }
+!
+! PR fortran/41872
+!
+! Character functions returning allocatable scalars
+!
+program test
+  implicit none
+  if (func () /= 'abc') call abort ()
+contains
+  function func() result (str)
+    character(len=3), allocatable :: str
+    if (allocated (str)) call abort ()
+    allocate (str)
+    str = 'abc'
+  end function func
+end program test