From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23085 invoked by alias); 4 Nov 2012 22:48:56 -0000 Received: (qmail 23062 invoked by uid 48); 4 Nov 2012 22:48:39 -0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/55207] Automatic deallocation of variables declared in the main program Date: Sun, 04 Nov 2012 22:48:00 -0000 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: janus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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 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: 2012-11/txt/msg00316.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55207 --- Comment #3 from janus at gcc dot gnu.org 2012-11-04 22:48:37 UTC --- The following patch applies the implicit SAVE attribute to variables declared in the main program: Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 193137) +++ gcc/fortran/decl.c (working copy) @@ -3812,9 +3812,11 @@ match_attr_spec (void) } } - /* Since Fortran 2008 module variables implicitly have the SAVE attribute. */ - if (gfc_current_state () == COMP_MODULE && !current_attr.save - && (gfc_option.allow_std & GFC_STD_F2008) != 0) + /* Since Fortran 2008, variables declared in a MODULE or PROGRAM + implicitly have the SAVE attribute. */ + if ((gfc_current_state () == COMP_MODULE + || gfc_current_state () == COMP_PROGRAM) + && !current_attr.save && (gfc_option.allow_std & GFC_STD_F2008) != 0) current_attr.save = SAVE_IMPLICIT; colon_seen = 1; This also removes the automatic allocation of both variables in the test case in comment 0. Therefore it has the same testsuite failures as the patch in comment 1 (possibly more?).