From patchwork Wed Oct 26 19:15:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 11406 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp442315wru; Wed, 26 Oct 2022 12:16:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7aC0M5dH16qKYbkRqzvCOGKjiSpllAfu2UH1cWzvsTVUbbUKQML/fr4aJPgoID711APFEf X-Received: by 2002:a17:906:4fcd:b0:78d:8059:17c with SMTP id i13-20020a1709064fcd00b0078d8059017cmr39910302ejw.423.1666811796879; Wed, 26 Oct 2022 12:16:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666811796; cv=none; d=google.com; s=arc-20160816; b=se/bHEBvLjPYbeehfNOtyjdSlBFsgWvRYTVHgG1ixJ16KTJSpHQxbgzYr0jvpmplB4 FmweZngzxykz4IPfShxqy0RdlDgtvkd7xCNTOtnztUnzZDb+MVyu/EJ+VXUiZmTdWvA/ UjqzMmL+EOO7MUtbsoCqTLmi1z6Cr5+VA2xQlZYu8+jMACMazyBzC79a036kYrfUpIif Rcw/IVu4g62q6lAVDutGIqAjXeezi3aDh4O7uKjy0QJ2znZa7qLyCY5RDgIF9sZJRIbD cn3KK21abSowCyuXezsl75fZCJxDu4J6Wy4yK61xM8HgeTL5hDaxBi0nnq73q2UsMpnA FqvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=UeX11FNH0Ndd4WFibFdvhESGfpY9P7+R4prhCzk82hY=; b=x4+yOtTliaNpYzxSrwPL1NrPasDoHgi2J10fZGrjEa/cJgxlGcGtZxLwmloKKH+AvY x1cm2GqPO5MmkqlzcJCuzAt0W0nvcQA9Uwx3n6Z0gcOF/rH64VyG2egu0RUACZtcARnu zBxtPksHqyq4IWAJgN8bqL9KpBI8EYQoo9xqM16YSKWeH4PCOtFRoWKc/0PBfdm1dycz 8T9LV/g8bqiPJjO6qnCVQJMvaJn4J6LGxVnTXOx+qTzxWCXTM0v6UhM4ce5t8G7Izcdr 9sWbSczhFpiThKGEGfNFeiwHqT6n5silQtHjpwYYqWQKFBuNSpaRU7zE7aKU5tbPBrrg I5lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rOHVgxNW; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ga11-20020a1709070c0b00b007309e8d567fsi372717ejc.145.2022.10.26.12.16.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:16:36 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rOHVgxNW; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D48183885522 for ; Wed, 26 Oct 2022 19:16:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D48183885522 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666811795; bh=UeX11FNH0Ndd4WFibFdvhESGfpY9P7+R4prhCzk82hY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=rOHVgxNW4Lloj0WIpFQzvB9vz3zxw3ALILCueQZK8+1rjc/6DuA70goabNOYEmup5 uumC+fYFqB+gjmRqGkz3gI5lZcbiGf9CEzZTDZioVnuelvcuzqlyCq1k8+74GHhwxB pNz1vqUUVsOhk6aOyVQsejLPMUh3S+bBmB52EP5w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id A8FC5388550D; Wed, 26 Oct 2022 19:15:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A8FC5388550D X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.85.70] ([93.207.85.70]) by web-mail.gmx.net (3c-app-gmx-bap72.server.lan [172.19.172.172]) (via HTTP); Wed, 26 Oct 2022 21:15:38 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: BOZ literal constants are not compatible to any type [PR103413] Date: Wed, 26 Oct 2022 21:15:38 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:stvW5U0KAABRZrM1OIc2k5uHEswzSAKr/+wYMJjH/pMzG6Zzkle5QvhTu06zZfxT2O+FG GrIgPWc1Qlg+CuFhzxDYhnaJjJmLuuMOuHWKC8cpaOr0bETfDDwo7dBQsybXGlrZmyfJ0PvnKO6w sWSk/qQrGIXRLgmBMfseaxsNTou0jkdMZ7pEL76/e/sWxlUhAE2lxA4Ay8WU3T3gN2Rf/OTyYS+R Nqiv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ID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS 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: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747778846622601619?= X-GMAIL-MSGID: =?utf-8?q?1747778846622601619?= Dear all, a BOZ as source-expression in an ALLOCATE statement could lead to an ICE when the allocate-object was a CLASS variable. Since a BOZ has no type, we can handle it as type incompatible with any type. This is also what the Cray compiler does for the code in the testcase. Regtested on x86_64-pc-linux-gnu. OK for mainline? The PR is marked as a 10/11/12/13 regression, so OK for backports? Thanks, Harald From 986bf9cc5abc51598609b16edc9242a87244571b Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 26 Oct 2022 21:00:44 +0200 Subject: [PATCH] Fortran: BOZ literal constants are not compatible to any type [PR103413] gcc/fortran/ChangeLog: PR fortran/103413 * symbol.cc (gfc_type_compatible): A boz-literal-constant has no type and thus is not considered compatible to any type. gcc/testsuite/ChangeLog: PR fortran/103413 * gfortran.dg/illegal_boz_arg_4.f90: New test. --- gcc/fortran/symbol.cc | 4 ++++ gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90 | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90 diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc index 6050359d521..49fb37864bd 100644 --- a/gcc/fortran/symbol.cc +++ b/gcc/fortran/symbol.cc @@ -5139,6 +5139,10 @@ gfc_type_compatible (gfc_typespec *ts1, gfc_typespec *ts2) bool is_union1 = (ts1->type == BT_UNION); bool is_union2 = (ts2->type == BT_UNION); + /* A boz-literal-constant has no type. */ + if (ts1->type == BT_BOZ || ts2->type == BT_BOZ) + return false; + if (is_class1 && ts1->u.derived->components && ((ts1->u.derived->attr.is_class diff --git a/gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90 b/gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90 new file mode 100644 index 00000000000..856cfa9211f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! { dg-options "-std=f2018" } +! PR fortran/103413 +! Contributed by G.Steinmetz + +program p + type t + class(*), allocatable :: a + end type + type(t) :: x + allocate (x%a, source=z'1') ! { dg-error "type incompatible" } + allocate (x%a, mold=z'1') ! { dg-error "type incompatible" } +end -- 2.35.3