From patchwork Mon Feb 17 14:07:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Eggleston X-Patchwork-Id: 1239254 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-519645-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=mHMmV2RU; 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 48Lm5R5qDCz9sRJ for ; Tue, 18 Feb 2020 01:07:22 +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=H8kN3jHex72+o2AeEiQ7N1vVR/kAph1gKtcX1js66ScEcl5NC4 3azstPB2ycXz3pz8cZ4wys8+95elaLHhSLucB8/2AZaeaJwJFBLQrRJ2n9KxO8B0 r12lMv6c8bhnPeECxpBFaczNvEJ9SL1nqjqTMG3YKLek+bha0Bj4U8D+s= 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=7JhXBw9iyMk/8GH97Hqa3V7Tw3A=; b=mHMmV2RUIY/0Y1/mfBlI wDvt5kZ+VXKFEsQK50Y6HY71Lu4dCN48RYVtKbzeb9PsKtacDApnEP02STvtOxtV 3hT2C5s3id3VL6Xf4vHZj6JgZqOMp1CmNqrGggHvFigktbJIfNWTEOLfSeufWalq vEYkcM5n97KPB5QBPgiWM3w= Received: (qmail 62280 invoked by alias); 17 Feb 2020 14:07:14 -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 62237 invoked by uid 89); 17 Feb 2020 14:07:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, KAM_NUMSUBJECT, KAM_SHORT, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy= 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; Mon, 17 Feb 2020 14:07:10 +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 1j3h3E-0002Rp-4h; Mon, 17 Feb 2020 14:07:08 +0000 To: gcc-patches , fortran From: Mark Eggleston Subject: [Regression, patch][Fortran] ICE: Invalid expression in gfc_element_size PR93601 Message-ID: <2a20bfff-f7df-3942-3790-7f08b5bd97b1@codethink.co.uk> Date: Mon, 17 Feb 2020 14:07:07 +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 fix for PR93601. gcc/fortran/ChangeLogs     Steven G. Kargl      PR fortran/93601     * match.c (gfc_match_assignment) : Reject assignment if     the lhs stype is BT_CLASS and the rhs type is BT_BOZ. gcc/testsuite/ChangeLogs     Mark Eggleston      PR fortran/93601     * gfortran.dg/pr93601.f90 : New test. Test using make with check-fortran on master at https://gcc.gnu.org/g:f82617f229b336d856c18313339b14657e05c129 OK to commit? From d5e4dab84324f3c31eeaf3bf22dd96503d34e654 Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Fri, 7 Feb 2020 15:33:38 +0000 Subject: [PATCH] [Fortran] ICE: Invalid expression in gfc_element_size PR93601 ICE occurs when assigning a BOZ constant to an class(*) variable with the allocatable attribute. Use of BOZ constants outside data statements and int/real/dble/cmplx intrinsics is not allowed. Original patch provided by Steven G. Kargl . gcc/fortran/ChangeLog PR fortran/93601 * match.c (gfc_match_assignment) : Reject assignment if the lhs stype is BT_CLASS and the rhs type is BT_BOZ. gcc/testsuite/ChangeLog PR fortran/93601 * gfortran.dg/pr93601.f90 : New test. --- gcc/fortran/match.c | 10 ++++++++++ gcc/testsuite/gfortran.dg/pr93601.f90 | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr93601.f90 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index a74cb8c5c19..5713dc20180 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -1348,6 +1348,16 @@ gfc_match_assignment (void) rvalue = NULL; m = gfc_match (" %e%t", &rvalue); + if (m == MATCH_YES + && rvalue->ts.type == BT_BOZ + && lvalue->ts.type == BT_CLASS) + { + m = MATCH_ERROR; + gfc_error ("BOZ literal constant at %L is neither a DATA statement " + "value nor an actual argument of INT/REAL/DBLE/CMPLX " + "intrinsic subprogram", &rvalue->where); + } + if (lvalue->expr_type == EXPR_CONSTANT) { /* This clobbers %len and %kind. */ diff --git a/gcc/testsuite/gfortran.dg/pr93601.f90 b/gcc/testsuite/gfortran.dg/pr93601.f90 new file mode 100644 index 00000000000..495447c637b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93601.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } + +program p + class(*), allocatable :: z + z = z'1' ! { dg-error "BOZ literal constant at" } +end + -- 2.11.0