From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43636 invoked by alias); 18 Sep 2015 19:40:32 -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 43593 invoked by uid 48); 18 Sep 2015 19:40:28 -0000 From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/67615] ICE on using arithmetic if with array instead of scalar Date: Fri, 18 Sep 2015 19:40: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: 5.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: 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: 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-09/txt/msg01517.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67615 --- Comment #4 from kargl at gcc dot gnu.org --- (In reply to kargl from comment #3) > This patch to resolve.c catches the problem. Watch for > cut-n-paste corruption of tabs. > > @@ -10377,12 +10381,11 @@ gfc_resolve_code (gfc_code *code, gfc_na > } > > case EXEC_ARITHMETIC_IF: > - if (t > - && code->expr1->ts.type != BT_INTEGER > - && code->expr1->ts.type != BT_REAL) > - gfc_error ("Arithmetic IF statement at %L requires a numeric " > - "expression", &code->expr1->where); > > + if (t && (code->expr1->rank > 0 || !gfc_numeric_ts > (&code->expr1->ts))) > + gfc_error ("Arithmetic IF statement at %L requires a scalar " > + "numeric expression", &code->expr1->where); > + > resolve_branch (code->label1, code); > resolve_branch (code->label2, code); > resolve_branch (code->label3, code); > > Whoops. Needs for for BT_COMPLEX. Better patch @@ -10377,12 +10381,13 @@ gfc_resolve_code (gfc_code *code, gfc_na } case EXEC_ARITHMETIC_IF: - if (t - && code->expr1->ts.type != BT_INTEGER - && code->expr1->ts.type != BT_REAL) - gfc_error ("Arithmetic IF statement at %L requires a numeric " - "expression", &code->expr1->where); + if (t && (code->expr1->rank > 0 + || !(code->expr1->ts.type == BT_REAL + || code->expr1->ts.type == BT_INTEGER))) + gfc_error ("Arithmetic IF statement at %L requires a scalar " + "REAL or INTEGER expression", &code->expr1->where); + resolve_branch (code->label1, code); resolve_branch (code->label2, code); resolve_branch (code->label3, code);