aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2011-01-27 23:47:08 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2011-01-27 23:47:08 +0100
commitf18694de283e54954b2012ffb66c2580e9ffd233 (patch)
tree08b614996b10745b0b2a84f1e65440a20e03ca12
parent2887665c943a4d67bda6f6410503fcfae6d6b7fa (diff)
downloadgcc-f18694de283e54954b2012ffb66c2580e9ffd233.zip
gcc-f18694de283e54954b2012ffb66c2580e9ffd233.tar.gz
gcc-f18694de283e54954b2012ffb66c2580e9ffd233.tar.bz2
re PR fortran/47474 (Wrong code with allocatable scalar, allocatable components as function result)
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. From-SVN: r169340
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/trans-decl.c12
2 files changed, 13 insertions, 5 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 2636170..f5380cd 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,11 @@
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
* options.c (gfc_handle_module_path_options): Save
module path without trailing slash as include path.
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 5e3afbe..74de59e 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -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)