From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19221 invoked by alias); 14 Mar 2014 20:20:48 -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 19184 invoked by uid 48); 14 Mar 2014 20:20:45 -0000 From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/60522] [4.7/4.8/4.9 Regression] WHERE construct causes an ICE in gfc_trans_where_2 Date: Fri, 14 Mar 2014 20:20: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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael 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-Flags: X-Bugzilla-Changed-Fields: cc 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: 2014-03/txt/msg01203.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60522 Mikael Morin changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mikael at gcc dot gnu.org --- Comment #3 from Mikael Morin --- BLOCK constructs are not allowed inside WHERE constructs. Thus, the "common function optimization" should not create a BLOCK to hold the temporary variables, at least not inside WHERE. Another possible fix, the following patch disables the optimization inside WHERE. diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 52bd700..dc641de 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -630,9 +630,16 @@ static int cfe_code (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED) { - current_code = c; - inserted_block = NULL; - changed_statement = NULL; + /* BLOCK constructs cannot appear inside WHERE blocks; as the optimization + may introduce the former we disable it inside the latter. */ + if ((*c)->op == EXEC_WHERE) + *walk_subtrees = 0; + else + { + current_code = c; + inserted_block = NULL; + changed_statement = NULL; + } return 0; }