From patchwork Tue Feb 11 12:10:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Eggleston X-Patchwork-Id: 1236262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519332-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=codethink.co.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=N9hpmycc; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48H1nt43mtz9sP7 for ; Tue, 11 Feb 2020 23:10:56 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Sxb+26rUeDzp/SWFUglMgEQARgpSk96iBh7to8hIsb4vzK8lx3 rZva9geatkSg89oD6bQAtKSMqObCnfnOoAFiHog/CPyBWzFRQk+ncxgVItxVziXY vCtOKIcpxR3R3Po9xxD9Wc+fvAFvi419tzV9CBRprpzLhk5Ypxr/nO1wY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=6dedEad6KxUtD35xh1GhiFv8yxU=; b=N9hpmyccas9AGYdWwR88 xBlzKJPtlHnOwtTTZJwpQ93YKkAMZbMwcIdOPQTer1QGtv6RfGqCd8Hi3wy9m504 u7NqpcGmlc6ohwuvhPkF/rcYt4FZtRyw4QfRxiROW4R8bHNLrTKUx9Dxw0KYVWDM DtuHAZ8L4u4L9hA7Vpq0Vw4= Received: (qmail 87180 invoked by alias); 11 Feb 2020 12:10:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 87137 invoked by uid 89); 11 Feb 2020 12:10:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, KAM_NUMSUBJECT, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=UD:co.uk, steven, check-fortran, checkfortran X-HELO: imap3.hz.codethink.co.uk Received: from imap3.hz.codethink.co.uk (HELO imap3.hz.codethink.co.uk) (176.9.8.87) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Feb 2020 12:10:45 +0000 Received: from [167.98.27.226] (helo=[10.35.5.172]) by imap3.hz.codethink.co.uk with esmtpsa (Exim 4.92 #3 (Debian)) id 1j1UNF-0007pZ-Uz; Tue, 11 Feb 2020 12:10:42 +0000 To: gcc-patches , fortran From: Mark Eggleston Subject: [PATCH] fortran: ICE using undeclared symbol in array constructor, PR93484 Message-ID: Date: Tue, 11 Feb 2020 12:10:41 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 Please find attached a patch for PR93484.  The original author is Steve Kargl. I have added the test cases. OK for master? running make produces the following for check-fortran gcc-8 and gcc-9 but not master: XPASS: gfortran.dg/typebound_call_22.f03   -O scan-tree-dump-times optimized "base \\(\\);" 1 What do I need to do to backport to gcc 8 and gcc 9 branches? The changelogs: gcc/fortran/ChangeLog     Steven G. Kargl      PR fortran/93484     * match.c (gfc_match_type_spec): Replace gfc_match_init_expr with     gfc_match_expr. Return m if m is MATCH_NO or MATCH_ERROR. gcc/testsuite/ChangeLog     Mark Eggleston      PR fortran/93484     * gfortran/pr93484_1.f90: New test.     * gfortran/pr93484_2.f90: New test. From 4a3db68ce1fc8696b0108b4b0633c1f0959dac80 Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Tue, 11 Feb 2020 08:35:02 +0000 Subject: [PATCH] fortran: ICE using undeclared symbol in array constructor PR93484 Using undeclared symbol k in an expression in the following array constructor results in an ICE: print *, [real(x(k))] If the call to the intrinsic is not in a constructor a no IMPLICIT type error is reported and the ICE does not occur. Matching on an expression instead of an initialisation express an and not converting a MATCH_ERROR return value into MATCH_NO results in the no IMPLICIT error and no ICE. Note: Steven G. Kargl is the author of the changes except for the test cases. gcc/fortran/ChangeLog: PR fortran/93484 * match.c (gfc_match_type_spec): Replace gfc_match_init_expr with gfc_match_expr. Return m if m is MATCH_NO or MATCH_ERROR. gcc/testsuite PR fortran/93484 * gfortran/pr93484_1.f90: New test. * gfortran/pr93484_2.f90: New test. --- gcc/fortran/match.c | 4 ++-- gcc/testsuite/gfortran.dg/pr93484_1.f90 | 8 ++++++++ gcc/testsuite/gfortran.dg/pr93484_2.f90 | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr93484_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr93484_2.f90 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index a74cb8c5c19..03adfca9bd9 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -2222,9 +2222,9 @@ gfc_match_type_spec (gfc_typespec *ts) found: - m = gfc_match_init_expr (&e); + m = gfc_match_expr (&e); if (m == MATCH_NO || m == MATCH_ERROR) - return MATCH_NO; + return m; /* If a comma appears, it is an intrinsic subprogram. */ gfc_gobble_whitespace (); diff --git a/gcc/testsuite/gfortran.dg/pr93484_1.f90 b/gcc/testsuite/gfortran.dg/pr93484_1.f90 new file mode 100644 index 00000000000..3b6dbc9ad79 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93484_1.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! +program p + implicit none + integer :: x(4) = [1,2,3,4] + print *, [real(x(k))] ! { dg-error "Symbol 'k' at .1. has no IMPLICIT type" } +end + diff --git a/gcc/testsuite/gfortran.dg/pr93484_2.f90 b/gcc/testsuite/gfortran.dg/pr93484_2.f90 new file mode 100644 index 00000000000..4a7f4330ed9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93484_2.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! +program p + implicit none + integer, parameter :: x(4) = [1,2,3,4] + print *, [real(x(k))] ! { dg-error "Symbol 'k' at .1. has no IMPLICIT type" } +end + -- 2.11.0