]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2011-01-27 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Jan 2011 22:47:08 +0000 (22:47 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Jan 2011 22:47:08 +0000 (22:47 +0000)
        PR fortran/47474
        * trans-decl.c (gfc_generate_function_code): Fix init
        of allocatable result variable with allocatable components.

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

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c

index 263617079bf5ff4013d168ca4ba0a76a7520dbbc..f5380cd511fcd20c0302a52109467955f90bee4b 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-27  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/47474
+       * trans-decl.c (gfc_generate_function_code): Fix init
+       of allocatable result variable with allocatable components.
+
 2011-01-27  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/47472
index 5e3afbe8219d0e4ec93d9c0d90a955ed14bee47c..74de59ea384b2b033151912abc9ccf3098c9be22 100644 (file)
@@ -4602,16 +4602,18 @@ gfc_generate_function_code (gfc_namespace * ns)
            && sym->attr.function
            && !sym->attr.pointer)
        {
-         if (sym->ts.type == BT_DERIVED
-             && sym->ts.u.derived->attr.alloc_comp)
+         if (sym->attr.allocatable && sym->attr.dimension == 0
+             && sym->result == sym)
+           gfc_add_modify (&init, result, fold_convert (TREE_TYPE (result),
+                                                        null_pointer_node));
+         else if (sym->ts.type == BT_DERIVED
+             && sym->ts.u.derived->attr.alloc_comp
+             && !sym->attr.allocatable)
            {
              rank = sym->as ? sym->as->rank : 0;
              tmp = gfc_nullify_alloc_comp (sym->ts.u.derived, result, rank);
              gfc_add_expr_to_block (&init, tmp);
            }
-         else if (sym->attr.allocatable && sym->attr.dimension == 0)
-           gfc_add_modify (&init, result, fold_convert (TREE_TYPE (result),
-                                                        null_pointer_node));
        }
 
       if (result == NULL_TREE)