From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30011 invoked by alias); 28 Nov 2010 13:48:03 -0000 Received: (qmail 29994 invoked by uid 22791); 28 Nov 2010 13:48:02 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 28 Nov 2010 13:47:57 +0000 From: "pault at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/35810] [TR 15581 / F2003] Automatic reallocation on assignment to allocatable variables X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pault at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sun, 28 Nov 2010 14:35:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-11/txt/msg03429.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35810 --- Comment #11 from Paul Thomas 2010-11-28 13:47:31 UTC --- Author: pault Date: Sun Nov 28 13:47:26 2010 New Revision: 167220 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167220 Log: 2010-11-28 Paul Thomas PR fortran/35810 * trans-array.c (gfc_trans_array_constructor): If the loop->to is a VAR_DECL, assume this is dynamic. In this case, use the counter to obtain the value and set loop->to appropriately. (gfc_conv_ss_descriptor): Always save the offset of a variable in info.saved_offset. (gfc_conv_ss_startstride): Do not attempt bound checking of the lhs of an assignment, if allocatable and f2003 is allowed. (gfc_conv_loop_setup): If possible, do not use an allocatable lhs variable for the loopspec. (gfc_is_reallocatable_lhs): New function. (get_std_lbound): New function. (gfc_alloc_allocatable_for_assignment): New function. * gfortran.h : Add flag_realloc_lhs to the options structure. * lang.opt : Add option f(no-)realloc-lhs. * invoke.texi : Document option f(no-)realloc-lhs. * options.c (gfc_init_options, gfc_post_options, gfc_handle_option): Incorporate f(no-)realloc-lhs with default to frealloc_lhs for -std > f95. * trans-array.h : Add primitive for previous. * trans-expr.c (gfc_conv_string_length): Return if character length is a variable and the expression is NULL. (gfc_conv_procedure_call): If the call is of the kind x = f(...) and the lhs is allocatable and reallocation on assignment OK, call gfc_alloc_allocatable_for_assignment. Do not generate the function call unless direct by reference. (realloc_lhs_loop_for_fcn_call): New function. (realloc_lhs_bounds_for_intrinsic_call): New function. (gfc_trans_arrayfunc_assign): Reallocation assignments need a loopinfo and for the loop bounds to be set. With intrinsic functions, free the lhs data and let the library allocate the data array. Done by the new functions above. (gfc_trans_assignment_1): If the lhs is allocatable and reallocation on assignment is allowed, mark the lhs and use gfc_alloc_allocatable_for_assignment to make the reallocation. * trans.h : Add is_alloc_lhs bitfield to gfc_ss structure. 2010-11-28 Paul Thomas