From patchwork Thu Feb 9 20:28:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 55092 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp556787wrn; Thu, 9 Feb 2023 12:29:15 -0800 (PST) X-Google-Smtp-Source: AK7set8/Q8b+zJIWizAW+IwN5kByG8d+0sms0BVnfHL3XOOdNalt+rzP1l+VGWERmeWcp1ZaGCYW X-Received: by 2002:a17:906:d793:b0:885:6d0f:4660 with SMTP id pj19-20020a170906d79300b008856d0f4660mr13816781ejb.22.1675974555164; Thu, 09 Feb 2023 12:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675974555; cv=none; d=google.com; s=arc-20160816; b=BcFIXICTp3wxkUsikzhhXwPA8IXwTONRZ0SbmLLhRYEvCmn2XutToyuBIUaKdS+F38 awar52EAKClV4fq3zvYOZ2vHeGDxk/CtIbH9c+x2RVaSzJhX+o0xTdEaxa9Q2zC/hHTB VGmGsoYZYMfoaqHnFHAMxufuVK+INLtyNwzjDpv+zlumb3Q2Q/ry6JyvYqeLvctMT29q svxHdjORgx1lyxUv1su2EjR+n9LSifp04Flcx99LQ61C6epf3dlvSyteS3H2dI2zfpeY tjEfwVqIGzApwnYmhZWmFinx90W0xIj6lAxi021eH8sGNo18U5SMkPosPHZTEW1voIXW 0hIg== 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=Z3SbOfkbSCzYeovArxKL6q9dO2kSguXK9+64JcmtShw=; b=ERYTCAWmjkvOjnMplHI5L6h9AijfNkm9rKwzxQjsfmXi+e3DFqnQweQ+vm7nRfZsrd K9SgfW2QOMz257OhsUCcq+RTDIdDfYFCR+ra+pRUsx5I3pPzZhIGDJHyiL5YHRkybBHi 9SzZ4bsyyGL9WJIZY1gaa9u8q5wGHKReP69o/NeXrZ81C4l0F34rcdcR8eTfZQ5cgYLv eLXXe3UL59sffc12uzeCpnOOKN8oHmXp17XpkbAOOkOzZwbXtaPWQENyhQ4nyG8uShiJ uIHiApgJCI4GhbsXa2sfhie4VbjqgX6+k9b1iK2Zqxu7Gj4o8NTf748GdBS65fW6XAXM seeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lnirH2sJ; 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 b7-20020aa7d487000000b004ab16fb53e2si2941207edr.566.2023.02.09.12.29.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 12:29:15 -0800 (PST) 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=lnirH2sJ; 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 08C723857400 for ; Thu, 9 Feb 2023 20:29:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08C723857400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675974554; bh=Z3SbOfkbSCzYeovArxKL6q9dO2kSguXK9+64JcmtShw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lnirH2sJ4qclbX3Y+94s0IiuNewDsZ5g8iHT5rO+oDhUwpizA7USdp3V/raAWI0Nt vGfEygtR/3zQxrmSfyNpRXhFMvaTO2nQ80zldNtFtmdZk/qrWOCdM90WvF0t8eHcCu oAm6UHinzepVz9JNPBbQf1iCkjfGK2hc2+oOegZk= 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.22]) by sourceware.org (Postfix) with ESMTPS id 18F1B3858C5F; Thu, 9 Feb 2023 20:28:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 18F1B3858C5F X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.88.106] ([93.207.88.106]) by web-mail.gmx.net (3c-app-gmx-bap49.server.lan [172.19.172.119]) (via HTTP); Thu, 9 Feb 2023 21:28:28 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: catch invalid kind in character conversion [PR69636,PR103779] Date: Thu, 9 Feb 2023 21:28:28 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:sNTURQGKLgbT6C3aE9KhhsIXDRcYo1nXuf1ZtyAtShuJpAITdwjO3q6gHQzg7T+pBVFl5 7bTBJiWeRfVkLJ+yaMciDKEUAU+z/klhNb+9MSU98VKNxU7THwilu5vx7/UAXw5/Pif7vP9rlttd zbggUvgIb0aEDil5FQF+ZooDH2cSHnS2Sv8zimk0UTqieddIX/YEKfGyyZWSQuz9H+6V6uSI7erO iOgOMX4wWx8zzzh7DF1/CeoSooBuzVhu6Ags26Jo9QcsPAcpHcsa+MHNH90svGHPZTWCeypNib8F nA= UI-OutboundReport: notjunk:1;M01:P0:XDfNZAvWtQQ=;Djd4SdDJM2zxzNCy2oke8XHgcSM Vj0SCEIGHTMs6D8NQKaM3+x8fI1w5u0vC0PxYjtx+faX5STS0I2sMCFORgX9k+QKZgOPSM85w +D/DNN1cw0xY4bg4tcTWrwtcaywBUv6HxWSFzC4sx0Fk0/ShQ2nSt7pcSTS5COgQdeMTuNYiS lzdDRiJ7QsFd0TFTNMc7SAN7QGSVLE3G1NzamNN8NeA4jVN4MkyphU3LpVOPMMAVp2qsWxbsv bAVpKfMxRhU1B57D5apy7i07gWmGjXYNiDt4T8e0SXdtLisSIi1ka64/VEFvxhIY6HAgkaUqJ sn2IDhqJliQrKd51zF3RqTfAURFhb0LX8glfU5ytNg1WF1aVeaHPwGY0HM4ZNXMdMbrKb/Lys KfOJsMYkYLLaArJ5SgX5Vkem4Ve1c6EF/4o8bTuEsJbhBF32jtod8cCgJdiSgMDOnz+VPctWW dJkpasXKvkXAtQZaSbUznFFhJEAnNoxTst+GkeEkl/sR7e+hAfEr/uI+07tp/UPI6mHqhcLHC w6ZqXdlpOkOY2sztoR1fS7NSdcIpxR7i1PIu5K8IlPuBB/oMxIn+ok39pgLohnUpe1qS5RqHh d/Lp1X9ZSUlbmZTrCCH6UmcqEeS/xW/1wYGCkmL13mWB7x+0fm/z4Yqf8stuBccrifYfzsFle cFM2CS8X0Y3iOAdkEZ8qZvpMtQkvmINPgXD24VPUStGUooFU8QqrhFJ36gnuuH+JMbicBXpA9 J1udqxBQhuUNnZO13I5UEldhsmYhCLCYNQVQSRdQwkkWfGOyRvdfKbY/bY2SEFiyX6kpAIVbh Mt2PrCytsgZncxltQJEYnKPg== X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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?1757386695146259287?= X-GMAIL-MSGID: =?utf-8?q?1757386695146259287?= Dear all, the attached trivial and obvious patch replaces an internal error on encountering an invalid kind in a character conversion by a regular error recovery. Pushed after regtesting on x86_64-pc-linux-gnu as r13-5760-ga618b45ac41cf480f54c4fa4014aed6218931290 Thanks, Harald From a618b45ac41cf480f54c4fa4014aed6218931290 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 9 Feb 2023 21:16:14 +0100 Subject: [PATCH] Fortran: catch invalid kind in character conversion [PR69636,PR103779] gcc/fortran/ChangeLog: PR fortran/69636 PR fortran/103779 * intrinsic.cc (gfc_convert_chartype): Recover on invalid character kind in conversion instead of generating an internal error. gcc/testsuite/ChangeLog: PR fortran/69636 PR fortran/103779 * gfortran.dg/pr103779.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/intrinsic.cc | 3 ++- gcc/testsuite/gfortran.dg/pr103779.f90 | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr103779.f90 diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc index 68f481473b4..17ee999c3b9 100644 --- a/gcc/fortran/intrinsic.cc +++ b/gcc/fortran/intrinsic.cc @@ -5419,7 +5419,8 @@ gfc_convert_chartype (gfc_expr *expr, gfc_typespec *ts) gcc_assert (expr->ts.type == BT_CHARACTER && ts->type == BT_CHARACTER); sym = find_char_conv (&expr->ts, ts); - gcc_assert (sym); + if (sym == NULL) + return false; /* Insert a pre-resolved function call to the right function. */ old_where = expr->where; diff --git a/gcc/testsuite/gfortran.dg/pr103779.f90 b/gcc/testsuite/gfortran.dg/pr103779.f90 new file mode 100644 index 00000000000..3d76c901e75 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103779.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! PR fortran/69636 +! PR fortran/103779 +! Contributed by G.Steinmetz + +character(1,) function f() ! { dg-error "Expected initialization expression" } + f = 'a' +end + +character(1,kind=) function g() ! { dg-error "Expected initialization expression" } + g = 'a' +end + +character(1,n) function h() ! { dg-error "has not been declared" } + h = 'a' +end + +! { dg-prune-output "Bad kind expression" } -- 2.35.3