------- Additional Comments From paulthomas2 at wanadoo dot fr 2005-07-10 17:22 ------- Subject: Re: problem with structure and calling a function
tobi at gcc dot gnu dot org wrote: >IOW, fixing the underlying bug is out-of-reach. The original bug can be fixed >by forcing the function result via a temporary as Paul's patch does. I'll have >to think about the correct check, though. > > > My current version of the patch compares the lvalue expr->ts.derived with the sym->ts.derived. This then allows derived type valued functions to go through gfc_trans_arrayfunc_assign but anything too difficult is sent to have a temporary made. Please find it attached. Paul T Index: gcc/gcc/fortran/trans-expr.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/fortran/trans-expr.c,v retrieving revision 1.53 diff -c -3 -p -r1.53 trans-expr.c *** gcc/gcc/fortran/trans-expr.c 25 Jun 2005 00:40:36 -0000 1.53 --- gcc/gcc/fortran/trans-expr.c 10 Jul 2005 17:19:50 -0000 *************** gfc_trans_assignment (gfc_expr * expr1, *** 2213,2221 **** tree tmp; stmtblock_t block; stmtblock_t body; ! ! /* Special case a single function returning an array. */ ! if (expr2->expr_type == EXPR_FUNCTION && expr2->rank > 0) { tmp = gfc_trans_arrayfunc_assign (expr1, expr2); if (tmp) --- 2213,2226 ---- tree tmp; stmtblock_t block; stmtblock_t body; ! ! /* Special case a single function returning an array. Note ! that derived type components on lhs do not benefit from ! this optimization and so are excluded by testing that ! the expression and symbol types are the same. */ ! if (expr2->expr_type == EXPR_FUNCTION && expr2->rank > 0 ! && expr1->symtree->n.sym->ts.derived ! == expr1->ts.derived) { tmp = gfc_trans_arrayfunc_assign (expr1, expr2); if (tmp) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18022