From patchwork Sat Dec 17 17:12:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry D X-Patchwork-Id: 1716919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=hMSztgMs; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NZCGx0GSFz240B for ; Sun, 18 Dec 2022 04:13:26 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B70083AA982E for ; Sat, 17 Dec 2022 17:13:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B70083AA982E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671297201; bh=Dzum/A732fPsizokcAFV0YcXCcXgE/7FeQifApgfiEY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hMSztgMs322JiVTScwS73kPqB+STv6rxTYltlfY3A9KQJs7XmrlrqU4tw3gmBKFrP 7L+2xCB9SgnSBLkqDq93FPI6L34LVjwBXezLXdyNfDdGvGlic6C3n7pARXUh2KKa02 HlFW/ap83UgVwsxTG4805IeF1QT/uPIbrZK6jzWs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 112543AA983C; Sat, 17 Dec 2022 17:12:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 112543AA983C Received: by mail-pg1-x52f.google.com with SMTP id v3so3696310pgh.4; Sat, 17 Dec 2022 09:12:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Dzum/A732fPsizokcAFV0YcXCcXgE/7FeQifApgfiEY=; b=QtRGUA5FdvemhwFxbsKvJxuzlSSwhvdOYHk/l37fdMtF2qkoYfKYqgHSR7AxMLGYYd wiBgMWmUGNpLOSQaH7nPRnT4fuCQarg5A25gRj4FU6d5/YAbZx9gbAA9dQiK6Vwwz54L e89VLOXL/6Yqpb+qzUtj7oPQeo2tbBYLg0yZ3wkaKlWjFv3I0Z9UoO/aekvm/23eOJLo A4JoR2yITtNHRYSsxpFkrZMukZ2tppZrmmZ3KWXZK82s669VJ9nEjlA449H8G6K1Ri7e Nsaz37qJvKWkG97BniJ6efJoUKrsmPeBOBHNKlDjovXIzSBTZj3xZhd/wMUgPY/QQ3/6 WOQw== X-Gm-Message-State: ANoB5pn5ZHIx6sWsyfEi08t45kZkk69woE+rY8wE+aXeOgbWwW2IOpO3 0G76ThGYgK0skfGZYihBPDFD0+l6hxg= X-Google-Smtp-Source: AA0mqf5a1hDaC+ptXeMhDh90nZcg1QANeo7irbccg2VnYyDRdAVsFNmz4uNzgzXWcGFc45qcRmWBdQ== X-Received: by 2002:aa7:8395:0:b0:575:dfe6:5df2 with SMTP id u21-20020aa78395000000b00575dfe65df2mr7554646pfm.2.1671297164621; Sat, 17 Dec 2022 09:12:44 -0800 (PST) Received: from [192.168.1.20] ([50.37.188.226]) by smtp.gmail.com with ESMTPSA id i185-20020a6287c2000000b0057a9b146592sm3364462pfe.186.2022.12.17.09.12.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 17 Dec 2022 09:12:44 -0800 (PST) Message-ID: <5dac7c39-c0e3-f7e7-8625-b672fc728e0c@gmail.com> Date: Sat, 17 Dec 2022 09:12:43 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Content-Language: en-US To: gfortran , gcc-patches Subject: [patch, fortran] PR107397 ICE in gfc_arith_plus, at fortran/arith.cc:654 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jerry D via Gcc-patches From: Jerry D Reply-To: Jerry D Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi all, The attached patch fixes a regression and is a patch from Steve. I have regression tested it and provided a test case. It is fairly simple and I will commit under the "simple" rule in a little while. Thanks Steve for Patch. Thanks Harald for helping me get back up to speed on the git magic. Regards, Jerry diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 0f9b2ced4c2..1562dc22bc6 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -2221,6 +2221,14 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus) sym->ts.f90_type = init->ts.f90_type; } + /* Catch the case: type(t), parameter :: x = z'1'. */ + if (sym->ts.type == BT_DERIVED && init->ts.type == BT_BOZ) + { + gfc_error ("Entity %qs at %L is incompatible with a BOZ " + "literal constant", name, &sym->declared_at); + return false; + } + /* Add initializer. Make sure we keep the ranks sane. */ if (sym->attr.dimension && init->rank == 0) { diff --git a/gcc/testsuite/gfortran.dg/pr107397.f90 b/gcc/testsuite/gfortran.dg/pr107397.f90 new file mode 100644 index 00000000000..4592a275e70 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr107397.f90 @@ -0,0 +1,9 @@ +!{ dg-do compile } +! +program p + type t + real :: a = 1.0 + end type + type(t), parameter :: x = z'1' ! { dg-error "incompatible with BOZ" } + x%a = x%a + 2 ! { dg-error "has no IMPLICIT type"} +end