diff options
author | Janus Weil <janus@gcc.gnu.org> | 2011-08-29 23:55:10 +0200 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2011-08-29 23:55:10 +0200 |
commit | 7a3eeb8555b6c14ccb9cd6b45ae0257da966fa07 (patch) | |
tree | e859dc72ff3060178030357a0a345be57c979755 /gcc/fortran | |
parent | 3167ec4a0bbfb94cab010af6c1c34f267e571cac (diff) | |
download | gcc-7a3eeb8555b6c14ccb9cd6b45ae0257da966fa07.zip gcc-7a3eeb8555b6c14ccb9cd6b45ae0257da966fa07.tar.gz gcc-7a3eeb8555b6c14ccb9cd6b45ae0257da966fa07.tar.bz2 |
re PR fortran/50225 ([OOP] The allocation status for polymorphic allocatable function results is not set properly)
2011-08-29 Janus Weil <janus@gcc.gnu.org>
PR fortran/50225
* trans-decl.c (gfc_generate_function_code): Nullify polymorphic
allocatable function results.
2011-08-29 Janus Weil <janus@gcc.gnu.org>
PR fortran/50225
* gfortran.dg/class_result_1.f03: New.
From-SVN: r178262
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-decl.c | 18 |
2 files changed, 19 insertions, 5 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a00723e..d47e411 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-08-29 Janus Weil <janus@gcc.gnu.org> + + PR fortran/50225 + * trans-decl.c (gfc_generate_function_code): Nullify polymorphic + allocatable function results. + 2011-08-29 Tobias Burnus <burnus@net-b.de> * trans-decl.c (generate_coarray_sym_init): Use diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index ead8acf..44363c2 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -5215,17 +5215,25 @@ gfc_generate_function_code (gfc_namespace * ns) { tree result = get_proc_result (sym); - if (result != NULL_TREE - && sym->attr.function - && !sym->attr.pointer) + if (result != NULL_TREE && sym->attr.function && !sym->attr.pointer) { 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_CLASS + && CLASS_DATA (sym)->attr.allocatable + && sym->attr.dimension == 0 && sym->result == sym) + { + tmp = CLASS_DATA (sym)->backend_decl; + tmp = fold_build3_loc (input_location, COMPONENT_REF, + TREE_TYPE (tmp), result, tmp, NULL_TREE); + gfc_add_modify (&init, tmp, fold_convert (TREE_TYPE (tmp), + null_pointer_node)); + } else if (sym->ts.type == BT_DERIVED - && sym->ts.u.derived->attr.alloc_comp - && !sym->attr.allocatable) + && 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); |