]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/41872 (wrong-code: Issues with allocatable scalars)
authorTobias Burnus <burnus@net-b.de>
Tue, 5 Jan 2010 07:19:30 +0000 (08:19 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Tue, 5 Jan 2010 07:19:30 +0000 (08:19 +0100)
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-05  Tobias Burnus  <burnus@net-b.de>

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

From-SVN: r155639

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 1e6501a31c5b17b5cc14f43e84a81d6818f889e3..6a594255dfe49d262443860bb9a42767e9bc370f 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 84eb585f5589e8734bbc6aebe2243c7b00a83962..e5fce02c6c7780c13c55af6e54569ce74b548abf 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 603f62977350ad37802ab01118dd7ca234c423d9..08622cb1fda2522c162572cf78eae37954091c25 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