From patchwork Wed Nov 16 21:58:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 21311 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp80747wrr; Wed, 16 Nov 2022 13:59:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf5FYzINFgc26TVVqvF6Ha17OqOP4l5IJbGudi7smRKRXYCU0yrFiUUgwlr2r2ZO141GeVu+ X-Received: by 2002:a17:906:dffc:b0:79e:8360:8c3d with SMTP id lc28-20020a170906dffc00b0079e83608c3dmr19969590ejc.146.1668635954048; Wed, 16 Nov 2022 13:59:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668635954; cv=none; d=google.com; s=arc-20160816; b=K4s3/utV5V20DnLbcMYldqy5bpzPiGRuIYilpMiugeqObeWKn1v0kcM29w+oGywU7W wFB2k1buHZCSEBxhNeMzCSfyEK/pR0TK7+rg4MalyutszGfzWYPmkTQH9fIfJiwrHUQZ FT7BLehPN9rcrB+1CcX6wnYzbFvKiakoYqV6J/mtO0tBWRWljikJ1y4qkeyki0FxhCXD MJ5LgKVgHRzAUdLk+HRwSmrfeFnLX7VWmOjnm2LBMudAuDCqGkkjhBOoL/8MJP4/9TSl lkqq98F/8o4I8anrL8UngZGPukKkAylSN2r5h0e61tXaYfpCiwZ9rsIiCzUvxIL+P4GX DAMA== 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=tIxmIvtYjrpMxfO1MNwwRrC7qJ/nD5+i07Ia/S5P4FI=; b=VOChO7EhnTfEGjyKOg5LR1//46BPMuQ1Dy8ggZdSL6VhYSAEtMfiSCwM+8+ZQl7MOM 4eW5IbYmTFkyQLqvl2zH3ZHxood5Z7vg9JvNxXR7nuZGBTmDdHxUIWOGFZaBl/Qb2Yf8 cCgZY/PXrjok8/nogWJhxq5GrA4jRRf9W6zE6wL2reZiTdMlgL4KPfBdeeUTNPjz7jxv 0UAFYahAs8p3hWzwGuPeyuMSmzpQVwgdmwvAPsojAkr45VQAA2Vn3s6OgMks4G1WaoGo Mk4K7cve3gbSR4319LN42hrst+xHwsSMX/6qXHY6C6McM2u421CiFoLupxzjiRqYG1tF H79Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mQexLSp5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i21-20020a170906251500b0077b4248b138si5630763ejb.127.2022.11.16.13.59.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 13:59:14 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mQexLSp5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 D619A396E031 for ; Wed, 16 Nov 2022 21:59:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D619A396E031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668635952; bh=tIxmIvtYjrpMxfO1MNwwRrC7qJ/nD5+i07Ia/S5P4FI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mQexLSp5TsMpcYKAKJ82J6rnjVriZ9/DG04mwmyfce1Do+5ZFRXyLNuzpq7igIZCf vpZws309MCovr7O6oWK2YoEDQKfukBjpf3TNnfngroBuH7NV2G4PSHYy9KL0tBWE1j qC35icp5r4Za7Wvtl4BOAT0kBMOFXKaDv5NLj/GQ= 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 1A8F1396DC39; Wed, 16 Nov 2022 21:58:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1A8F1396DC39 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.86.187] ([93.207.86.187]) by web-mail.gmx.net (3c-app-gmx-bap19.server.lan [172.19.172.89]) (via HTTP); Wed, 16 Nov 2022 22:58:18 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: ICE on procedure arguments with non-integer length [PR107707] Date: Wed, 16 Nov 2022 22:58:18 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:hiN9ygfQpiFskFnwN0hArvu2VL3xcivwkFTFNh2nQhtcXASSCXAyZawrEhIi+UTh3CAUb wx+lXtrTNzVWUOkOUqe9OpLs4mLOREjZCbdOLclSh0q2+WgrFTvy3aGB3nAoDXtJ0xdFljtMfRNP acjKNr4J891i0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ES_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?1749691614026299813?= X-GMAIL-MSGID: =?utf-8?q?1749691614026299813?= Dear all, I've committed the attached patch for Steve after regtesting. It obviously checks the types of character length to be integer before passing them to mpz_*. Pushed as r13-4113-gbdd784fc48a283d54f5f1e3cc2a0668c14dd3bee Thanks, Harald @Steve: please close PR if you think everything is ok. From bdd784fc48a283d54f5f1e3cc2a0668c14dd3bee Mon Sep 17 00:00:00 2001 From: Steve Kargl Date: Wed, 16 Nov 2022 22:46:55 +0100 Subject: [PATCH] Fortran: ICE on procedure arguments with non-integer length [PR107707] gcc/fortran/ChangeLog: PR fortran/107707 * interface.cc (gfc_compare_actual_formal): Check that we actually have integer values before asking gmp_* to use them. gcc/testsuite/ChangeLog: PR fortran/107707 * gfortran.dg/pr107707.f90: New test. --- gcc/fortran/interface.cc | 2 ++ gcc/testsuite/gfortran.dg/pr107707.f90 | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr107707.f90 diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc index 49dbd1d886c..616ae2b1197 100644 --- a/gcc/fortran/interface.cc +++ b/gcc/fortran/interface.cc @@ -3273,9 +3273,11 @@ gfc_compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal, if (a->expr->ts.type == BT_CHARACTER && a->expr->ts.u.cl && a->expr->ts.u.cl->length && a->expr->ts.u.cl->length->expr_type == EXPR_CONSTANT + && a->expr->ts.u.cl->length->ts.type == BT_INTEGER && f->sym->ts.type == BT_CHARACTER && f->sym->ts.u.cl && f->sym->ts.u.cl->length && f->sym->ts.u.cl->length->expr_type == EXPR_CONSTANT + && f->sym->ts.u.cl->length->ts.type == BT_INTEGER && (f->sym->attr.pointer || f->sym->attr.allocatable || (f->sym->as && f->sym->as->type == AS_ASSUMED_SHAPE)) && (mpz_cmp (a->expr->ts.u.cl->length->value.integer, diff --git a/gcc/testsuite/gfortran.dg/pr107707.f90 b/gcc/testsuite/gfortran.dg/pr107707.f90 new file mode 100644 index 00000000000..a8be2b5b299 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr107707.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! PR fortran/107707 - ICE in gfc_compare_actual_formal +! Contributed by G.Steinmetz + +program p + character(3), allocatable :: c + c = 'abc' + call s(c) +contains + subroutine s(x) + character(real(3)), allocatable :: x ! { dg-error "must be of INTEGER type" } + end +end -- 2.35.3