From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2071) id 3C09B3858D38; Fri, 28 Oct 2022 20:56:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C09B3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666990619; bh=adTmu0FcsiOBwqC7t7JsGfQNTIk86n/X2tAS30EnccA=; h=From:To:Subject:Date:From; b=JST8diLA9VfiQhP3XnAO/IuybxQxbJ7lDdOLnWqUuxRRwmiL7as0qUyddIIUcfQkv MX5EbPOMps9eARTzwD0wfjOH5FDoPrmr48oCOaUhlp8X8UqoKCm90SdHQCMyj2oI5J N1zpPGX56oFDMLgLd0geYoeq2idR8yy4szKRyzQQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Harald Anlauf To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-11063] Fortran: BOZ literal constants are not compatible to any type [PR103413] X-Act-Checkin: gcc X-Git-Author: Harald Anlauf X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 0586159b57426ed7d235b42f38681213c3183892 X-Git-Newrev: 3b4c9e0658b13b8db6c7f38242ed270cdb8fc932 Message-Id: <20221028205659.3C09B3858D38@sourceware.org> Date: Fri, 28 Oct 2022 20:56:57 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3b4c9e0658b13b8db6c7f38242ed270cdb8fc932 commit r10-11063-g3b4c9e0658b13b8db6c7f38242ed270cdb8fc932 Author: Harald Anlauf Date: Wed Oct 26 21:00:44 2022 +0200 Fortran: BOZ literal constants are not compatible to any type [PR103413] gcc/fortran/ChangeLog: PR fortran/103413 * symbol.c (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. (cherry picked from commit f7d28818179247685f3c101f9f2f16366f56309b) Diff: --- gcc/fortran/symbol.c | 4 ++++ gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90 | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 96e4cee3040..dff4b7f1659 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -5123,6 +5123,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