From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56130 invoked by alias); 18 Oct 2015 17:18: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 Received: (qmail 56089 invoked by uid 55); 18 Oct 2015 17:17:55 -0000 From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/67758] [6 Regression] ICE on invalid use of COMMON Date: Sun, 18 Oct 2015 17:18: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-Version: 6.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: mikael at gcc dot gnu.org X-Bugzilla-Target-Milestone: 6.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg01425.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67758 --- Comment #8 from Mikael Morin --- Author: mikael Date: Sun Oct 18 17:17:21 2015 New Revision: 228947 URL: https://gcc.gnu.org/viewcvs?rev=228947&root=gcc&view=rev Log: Fix common-related error recovery ICE. Fix an inconsistent state, between the in_common attribute and the common_block pointer. - adding a symbol to a common block list in gfc_match_common is delayed after the call to gfc_add_in_common. - gfc_restore_latest_undo_checkpoint is changed to check the common_block pointer directly instead of the in_common attribute. - gfc_restore_old_symbol is changed to also restore the common-related pointers. This is done using a new function created to factor the related memory management. - In gfc_restore_last_undo_checkpoint, when a symbol has been removed from the common block linked list, its common_next pointer is cleared. PR fortran/67758 gcc/fortran/ * gfortran.h (gfc_symbol): Expand comment. * match.c (gfc_match_common): Delay adding the symbol to the common_block after the gfc_add_in_common call. * symbol.c (gfc_free_symbol): Move common block memory handling... (gfc_set_symbol_common_block): ... here as a new function. (restore_old_symbol): Restore common block fields. (gfc_restore_last_undo_checkpoint): Check the common_block pointer instead of the in_common attribute. When a symbol has been removed from the common block linked list, clear its common_next pointer. gcc/testsuite/ * gfortran.dg/common_25.f90: New file. Added: trunk/gcc/testsuite/gfortran.dg/common_25.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/match.c trunk/gcc/fortran/symbol.c trunk/gcc/testsuite/ChangeLog