From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16732 invoked by alias); 10 Jul 2005 17:22:45 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 16713 invoked by alias); 10 Jul 2005 17:22:41 -0000 Date: Sun, 10 Jul 2005 17:25:00 -0000 Message-ID: <20050710172241.16711.qmail@sourceware.org> From: "paulthomas2 at wanadoo dot fr" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20041015190149.18022.gruel@astro.ufl.edu> References: <20041015190149.18022.gruel@astro.ufl.edu> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug fortran/18022] problem with structure and calling a function X-Bugzilla-Reason: CC X-SW-Source: 2005-07/txt/msg01185.txt.bz2 List-Id: ------- 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