From patchwork Mon Feb 17 11:26:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Eggleston X-Patchwork-Id: 1239138 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-519632-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=vB5S0cqr; 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 48LhXQ4qyHz9sNg for ; Mon, 17 Feb 2020 22:27:00 +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=c+PQI58J6Lc4HxkhvzBuke3/r45mmZ3BrGKIWgyQIs6PxYXRwc GQKIVjiT1kt88IZnpKJj34ACezSrpUkKjl7UMVAM77OaggA+ENairVfYC70YGiE8 RLDn14l7ggdbX+/bLdXoD2RlX/oDqhzkCa8Kgv7DREux5xuUVvWS6AGKg= 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=ePMpmMtEQqh/lCzh0gKXb9QbCOw=; b=vB5S0cqrlcjDLJkQsO70 bBHzY3ocFrYTgitrJKJruNl9JOQQd7mm9UvvIViwyIXCwf091Pd6WZSWGtsVGZWe Iyr9Dwd+kwV0HbTE4ovM1fmCLK2TBgt2JeHGDWfBvPZUAmeniFJPUCe+McgKchPZ 1NnbIxF2sPsMBbJLqw1L4Ss= Received: (qmail 26115 invoked by alias); 17 Feb 2020 11:26:52 -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 26099 invoked by uid 89); 17 Feb 2020 11:26:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.1 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=H*F:D*co.uk, UD:uk, UD:co.uk, H*Ad:D*co.uk 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 11:26:49 +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 1j3eY2-0007Yh-Ii; Mon, 17 Feb 2020 11:26:46 +0000 To: gcc-patches , fortran From: Mark Eggleston Subject: [Regression, patch][Fortran] ICE in gfc_conv_constant_to_tree PR93604 Message-ID: <1c85a4a2-75ca-e06f-ced2-cdd97c7de9cf@codethink.co.uk> Date: Mon, 17 Feb 2020 11:26:46 +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 patch for PR93604. gcc/fortran/ChangeLog     Steven G. Kargl      PR fortran/93604     * decl.c (gfc_match_data) : Check whether the data expression     is a derived type and is a constructor. If a BOZ constant     is encountered in the constructor output an error and return     MATCH_ERROR. gcc/testsuite/ChangeLog     Mark Eggleston      PR fortran/93604     * gfortran.dg/pr93604.f90 : New test. OK to commit? From b4bd5742d842c860da5b35955301e3c1a1e06160 Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Thu, 6 Feb 2020 13:42:33 +0000 Subject: [PATCH] [Fortran] ICE in gfc_conv_constant_to_tree PR93604 Using a BOZ constant in a structure constructor in a data statement resulted in an ICE. Output a "BOZ literal constant cannot appear in a structure constructor" error message instead. Original patch provided by Steven G. Kargl . Test case added later. gcc/fortran/ChangeLog * decl.c (gfc_match_data) : Check whether the data expression is a derived type and is a constructor. If a BOZ constant is encountered in the constructor output an error and return MATCH_ERROR. gcc/testsuite/ChangeLog * gfortran.dg/pr93604.f90 : New test. --- gcc/fortran/decl.c | 16 ++++++++++++++++ gcc/testsuite/gfortran.dg/pr93604.f90 | 10 ++++++++++ 2 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr93604.f90 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 499d2429aba..7382fea03e4 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -716,6 +716,22 @@ gfc_match_data (void) new_data->next = gfc_current_ns->data; gfc_current_ns->data = new_data; + /* A BOZ literal constant cannot appear in a structure constructor. + Check for that here for a data statement value. */ + if (new_data->value->expr->ts.type == BT_DERIVED + && new_data->value->expr->value.constructor) + { + gfc_constructor *c; + c = gfc_constructor_first (new_data->value->expr->value.constructor); + for (; c; c = gfc_constructor_next (c)) + if (c->expr->ts.type == BT_BOZ) + { + gfc_error ("BOZ literal constant at %L cannot appear in a " + "structure constructor", &c->expr->where); + return MATCH_ERROR; + } + } + if (gfc_match_eos () == MATCH_YES) break; diff --git a/gcc/testsuite/gfortran.dg/pr93604.f90 b/gcc/testsuite/gfortran.dg/pr93604.f90 new file mode 100644 index 00000000000..2c695d37829 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93604.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } + +program p + type t + integer :: a + end type + type(t) :: x + data x /t(z'1')/ ! { dg-error "cannot appear in a structure constructor" } +end + -- 2.11.0