aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/resolve.c
diff options
context:
space:
mode:
authorAndre Vehreschild <vehre@gmx.de>2015-07-06 12:26:12 +0200
committerAndre Vehreschild <vehre@gcc.gnu.org>2015-07-06 12:26:12 +0200
commitc16126ac1815c23771abc76d7daa30662dc31379 (patch)
treec52a82843f3c1435cfba1b2ed903bdb4e71476cb /gcc/fortran/resolve.c
parentc8ba649886633947106b28f1ebf43b3b0d86be6c (diff)
downloadgcc-c16126ac1815c23771abc76d7daa30662dc31379.zip
gcc-c16126ac1815c23771abc76d7daa30662dc31379.tar.gz
gcc-c16126ac1815c23771abc76d7daa30662dc31379.tar.bz2
re PR fortran/58586 (ICE with derived type with allocatable component passed by value)
gcc/testsuite/ChangeLog: 2015-07-06 Andre Vehreschild <vehre@gmx.de> PR fortran/58586 * gfortran.dg/alloc_comp_class_3.f03: New test. * gfortran.dg/alloc_comp_class_4.f03: New test. gcc/fortran/ChangeLog: 2015-07-06 Andre Vehreschild <vehre@gmx.de> PR fortran/58586 * resolve.c (resolve_symbol): Non-private functions in modules with allocatable or pointer components are marked referenced now. Furthermore is the default init especially for those components now done in gfc_conf_procedure_call preventing duplicate code. * trans-decl.c (gfc_generate_function_code): Generate a fake result decl for functions returning an object with allocatable components and initialize them. * trans-expr.c (gfc_conv_procedure_call): For value typed trees use the tree without indirect ref. And for non-decl trees add a temporary variable to prevent evaluating the tree multiple times (prevent multiple function evaluations). * trans.h: Made gfc_trans_structure_assign () protoype available, which is now needed by trans-decl.c:gfc_generate_ function_code(), too. From-SVN: r225447
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r--gcc/fortran/resolve.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index efafabc..d16bf13 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -14083,10 +14083,15 @@ resolve_symbol (gfc_symbol *sym)
if ((!a->save && !a->dummy && !a->pointer
&& !a->in_common && !a->use_assoc
- && (a->referenced || a->result)
- && !(a->function && sym != sym->result))
+ && !a->result && !a->function)
|| (a->dummy && a->intent == INTENT_OUT && !a->pointer))
apply_default_init (sym);
+ else if (a->function && sym->result && a->access != ACCESS_PRIVATE
+ && (sym->ts.u.derived->attr.alloc_comp
+ || sym->ts.u.derived->attr.pointer_comp))
+ /* Mark the result symbol to be referenced, when it has allocatable
+ components. */
+ sym->result->attr.referenced = 1;
}
if (sym->ts.type == BT_CLASS && sym->ns == gfc_current_ns