From patchwork Fri Jan 5 21:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 185554 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6505973dyb; Fri, 5 Jan 2024 14:43:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhaBPVWsxS7eoOs6/dMlVSLzcjuHiHHvNeduEm5gbXfC/ncXdxjnuJ2GOrJs7CEn1Zzrcm X-Received: by 2002:ac8:5c86:0:b0:429:74f4:5ace with SMTP id r6-20020ac85c86000000b0042974f45acemr166896qta.66.1704494583126; Fri, 05 Jan 2024 14:43:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704494583; cv=pass; d=google.com; s=arc-20160816; b=vJkD57CfZze65yHm3TOherPBGgLRyXY4DW8KEvzToEr9HHpikDmZGl2o4VLzDK1NTK hE0VTixFFp1JJ4ZVgrvHNii2R8lIB60WAwX9bLVEbKOiDVGgy0uCd6T5kY3XWLwpsFMm DCj5Vf0lqQv31jPQdZXV/Kklx9v2Q9wfNEsSTYhJDcJv8zQ8zfUTm/aH9gOqfEt622sI h4VPpiETCuG5HWp21Ni4F84t2fYOLiEjGAknCQzStvIKkPX7KD2PPK5CBmM3ohDU5wSQ z9ghUOezPqVoPgmUfRDQ5N3cSQu4s7qTekZOZYPuxDw/V0/ScDxLJtcut7QCuhKEBlmE pAkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:ui-outboundreport:sensitivity :importance:date:subject:to:from:message-id:mime-version :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=raC3ZKKASeC52FeVkTRsFIXHVnkXSlIsFtTbqOOfkBo=; fh=+IEfvAe+9BRgPHWhQEl2uIBTtAiiGDh1ExRZeB5JJoc=; b=IyGEqTdO363c5BxZkcQ8EIgik1OVgh3ZC5gb1Rc6Cryz1jLn7I12vykEokUkLc/gyR tSFMf3zDVqzHSCu2eRd7Aj56RbuLMq1aHFRsWD8h6TwJnaSdJrRB8Bex9T8yq6/VJD2k OTmbRi94LFWaCXvyldcoXE5cT3hYwoqEm7BMzkFesNfVvhqVhmZ3d8Bd21GYZg3D/EdL UvnnZy+ke4vCqEeD3KECUSyKBiSmuuAZRAx8IQvuS63uCDbZohiP86DaRVsE9TDG++tD ZZJgj7PCl9qT73E/LaWacFwcexCpU+wIVlUyY9MDjXpz7QjVxSZxqKQ6Nlws2RWJxm3l Lm1g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=SLaNYJMv; arc=pass (i=1); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b20-20020a05622a021400b0042925ba5727si2931117qtx.272.2024.01.05.14.43.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 14:43:03 -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=@gmx.de header.s=s31663417 header.b=SLaNYJMv; arc=pass (i=1); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69A103857C6B for ; Fri, 5 Jan 2024 21:39:20 +0000 (GMT) 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.15.15]) by sourceware.org (Postfix) with ESMTPS id 1A9763858D1E; Fri, 5 Jan 2024 21:38:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A9763858D1E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1A9763858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.15.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704490711; cv=none; b=Vz9PsqDQdh1gXOSS0XfQBAfF0Jbk4+arP3ykwdJukRNC0U1Fpd9fVs3tLG7FYWovnKM1ujOHYMunNuM9ZLz6JKQUh1ntdjhFBGY3DdKtU4zmFYHNU6F+rxfgH34wyPqrVqJWcV/WnLtU09yJJ41CdaLpfGkZ+BJ6WGF3BlFVsys= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704490711; c=relaxed/simple; bh=91bcCOqDO4LNjSwX2rT+kLsNSk7Rc3PAgTZu2X7rB3Q=; h=DKIM-Signature:MIME-Version:Message-ID:From:To:Subject:Date; b=tN1Ocz9EpBlgn4zvUYqUuSaHU7BTmmja5n/nhenHuNNvIkM6zOfGCtT+m9UAEE9DHWRKU0QRiGp2YOI4C8tKL4as5oAYUWbSXOEKvvcPERWKHyi24hdUIlrktgj8lFKRKcyFix5rxt/FcVn53pyG3K7JOzqh2RXkHGkZLd2Sa/c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1704490707; x=1705095507; i=anlauf@gmx.de; bh=91bcCOqDO4LNjSwX2rT+kLsNSk7Rc3PAgTZu2X7rB3Q=; h=X-UI-Sender-Class:From:To:Subject:Date; b=SLaNYJMvpsNpi7JG5AVyFLWDmOsFonIdHmFrT1jlFHA6ytLOwJme6pyhCrJjzQTs dhFuyN/Sq+uT6wyQp9a4kKFiw44HktQrUAGj+b3FSCzYHPLI6sQO03N0ZM4zeh6Ei NwsHWpwDu9ikcUbSTqfa+DG80dd6/hN2/zC7IqeBJ8UMix4ztzf3w9IQ+IOrI1lbM zcZw5GW6+6Mu+MKF01hdjqIpLq/fiQmlFSOVeHtdl4VOWD5/+va9M9sLZj9rLjP1l slDFwHnugOylV0ZU7EvrfDLGX32R4HdM+rkHnhJWpaklbJKMmLYhfjGUC/BhnJBKb ingoRtQGNTLSpmyFcw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [79.232.146.155] ([79.232.146.155]) by web-mail.gmx.net (3c-app-gmx-bs15.server.lan [172.19.170.67]) (via HTTP); Fri, 5 Jan 2024 22:38:27 +0100 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH] Fortran: bogus warnings with REPEAT intrinsic and -Wconversion-extra [PR96724] Date: Fri, 5 Jan 2024 22:38:27 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:75xW6CBQm4L83LnslQyVObH+YcgXtiSC659Rv3yMLmtuVwLPJtpkamjC745xjMzl7Knew fSuVWe6GgKkSHWMXiIRTp/Ka3kuQyiLza03fVw03Cr6yf/aQ/DAdMO2W5ns53SS83B8wW2TkV4BB A7dgXJRD/xUvEBmLGTaDv8eRxr9keierrN9BdYNU5V4KPq3mKnY9Dynyozg7SyQChY6qbDSjHeHk QKvTzQ7ySXonVUIkh66TPeJwTR6xnPX4Rp9zXPsJWcDEKHNfVQZ4kqWdXa0NAkkaRGJl11/UugPq RY= UI-OutboundReport: notjunk:1;M01:P0:lyRk3gy256Q=;s8O5pPFxzc2dbpWeOAVdMKAHqzP JgA8BIZ6pMCE1h626WHf11DwOXmx9ZOWkc7qA7Uf7BHclep6XJ4hohtcb0BzyuuCH3Fx93k6b d2vdguOSq3fO7EipBf9U3y7YAZL143VfmeMjE3fn+VB832hSMeVyfgSRl1pUrQpFKbWQt8FrP O1KwIJRP/O4t6TqEeVSFkKTSil4dD7d9iO1d3ik8dVs3LLehU2ZOC8UofL7LI/A+ddq4r+9zd e+DA/IxszCdFymuqCtskMGihdXYUGA58mVfDsjwy5GoDSVPLFkbCAOUgtHH9Y6soKXD3tjVWt Klpj6NUi1kdvW1G2N1dtOKJWSCY3NXZJTelSVFN9WYeg8jGRoxiifj5r97HWoJkc7FNmhCtnQ j+BShnu2gKrcYGxrQCLZ8RgNbuMjJlKMEem4zEN1T3MiTBZTFGzVjQiNppdzm5VLfhYn1q9C8 bOig1fPCXrYs16v/2+Sby+n+hg2Hfbp3QTMCU5Ocl4XxgxR+FC5eemxoAwi5khW118AVdCHoV +a0xs2x6bkmS5bbyGmGMGgVYHvD689b0X2wrJdULobCtEdmtnNNDR9fVNs0nDePiv7iUWLOfL Q2MiRPB8KVVxg0rB3ARkArz5EU17V0bu6ogXWb8O5JFDdk8EEEwcfDXjs0FJSlKnhFp4vxo91 iaKWnuy3yayubID+fNbQuPhaxCT91vTahwR+IIuvla1fust7DTsxJsM+cinDUGAHYgVXF4ROS OsZaGMS3SmufaX1kDzP6lcHyIPD/c8IZFNznjVRkOX8+YS7Sj0ORDXmHhfZJebqnOHkFqPVQ7 BuJzzs3zFUOOeEKtCp+UfXzg== X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787292111695475627 X-GMAIL-MSGID: 1787292111695475627 Dear all, the attached patch picks up a submission by Jose that was never reviewed: https://gcc.gnu.org/pipermail/fortran/2020-August/054902.html The original patch was unnecessarily complex, as it could invoke more conversions than necessary. I chose to only convert to the essential - and common - gfc_charlen_int_kind. It's almost trivial now. Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald From 18f212aaca8a13fbd2f40cc7636b1a20185cc01e Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 5 Jan 2024 22:24:25 +0100 Subject: [PATCH] Fortran: bogus warnings with REPEAT intrinsic and -Wconversion-extra [PR96724] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc/fortran/ChangeLog: PR fortran/96724 * iresolve.cc (gfc_resolve_repeat): Force conversion of NCOPIES to gfc_charlen_int_kind before call to gfc_multiply. gcc/testsuite/ChangeLog: PR fortran/96724 * gfortran.dg/repeat_8.f90: New test. Co-authored-by: José Rui Faustino de Sousa --- gcc/fortran/iresolve.cc | 7 +- gcc/testsuite/gfortran.dg/repeat_8.f90 | 123 +++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/repeat_8.f90 diff --git a/gcc/fortran/iresolve.cc b/gcc/fortran/iresolve.cc index 5bb0bbc477b..f25a5ba3aef 100644 --- a/gcc/fortran/iresolve.cc +++ b/gcc/fortran/iresolve.cc @@ -2363,7 +2363,12 @@ gfc_resolve_repeat (gfc_expr *f, gfc_expr *string, } if (tmp) - f->ts.u.cl->length = gfc_multiply (tmp, gfc_copy_expr (ncopies)); + { + /* Force-convert ncopies to gfc_charlen_int_kind. */ + gfc_expr *e = gfc_copy_expr (ncopies); + gfc_convert_type_warn (e, &tmp->ts, 2, 0); + f->ts.u.cl->length = gfc_multiply (tmp, e); + } } diff --git a/gcc/testsuite/gfortran.dg/repeat_8.f90 b/gcc/testsuite/gfortran.dg/repeat_8.f90 new file mode 100644 index 00000000000..9dd379ac96b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/repeat_8.f90 @@ -0,0 +1,123 @@ +! { dg-do compile } +! { dg-additional-options "-Wconversion-extra" } +! +! Test fix for PR fortran/96724 +! +! Contributed by José Rui Faustino de Sousa + +program repeat_p + use, intrinsic :: iso_fortran_env, only: int8, int16, int32, int64 + implicit none + + integer, parameter :: n = 20 + integer, parameter :: ucs4 = selected_char_kind ('ISO_10646') + + integer(kind=int8), parameter :: p08 = int(n, kind=int8) + integer(kind=int16), parameter :: p16 = int(n, kind=int16) + integer(kind=int16), parameter :: p32 = int(n, kind=int32) + integer(kind=int16), parameter :: p64 = int(n, kind=int64) + + integer(kind=int8) :: i08 + integer(kind=int16) :: i16 + integer(kind=int32) :: i32 + integer(kind=int64) :: i64 + + character(len=n,kind=1) :: c + character(len=n,kind=ucs4) :: d + + i08 = p08 + c = repeat('X', 20_int8) + c = repeat('X', i08) + c = repeat('X', p08) + c = repeat('X', len08(c)) + d = repeat(ucs4_'X', 20_int8) + d = repeat(ucs4_'X', i08) + d = repeat(ucs4_'X', p08) + d = repeat(ucs4_'X', len08(c)) + i16 = p16 + c = repeat('X', 20_int16) + c = repeat('X', i16) + c = repeat('X', p16) + c = repeat('X', len16(c)) + d = repeat(ucs4_'X', 20_int16) + d = repeat(ucs4_'X', i16) + d = repeat(ucs4_'X', p16) + d = repeat(ucs4_'X', len16(c)) + i32 = p32 + c = repeat('X', 20_int32) + c = repeat('X', i32) + c = repeat('X', p32) + c = repeat('X', len32(c)) + d = repeat(ucs4_'X', 20_int32) + d = repeat(ucs4_'X', i32) + d = repeat(ucs4_'X', p32) + d = repeat(ucs4_'X', len32(c)) + i64 = p64 + c = repeat('X', 20_int64) + c = repeat('X', i64) + c = repeat('X', p64) + c = repeat('X', len64(c)) + d = repeat(ucs4_'X', 20_int64) + d = repeat(ucs4_'X', i64) + d = repeat(ucs4_'X', p64) + d = repeat(ucs4_'X', len64(c)) + +contains + + function len08(x) result(l) + character(len=*), intent(in) :: x + integer(kind=int8) :: l + + l = int(len(x), kind=int8) + end function len08 + + function len16(x) result(l) + character(len=*), intent(in) :: x + integer(kind=int16) :: l + + l = int(len(x), kind=int16) + end function len16 + + function len32(x) result(l) + character(len=*), intent(in) :: x + integer(kind=int32) :: l + + l = int(len(x), kind=int32) + end function len32 + + function len64(x) result(l) + character(len=*), intent(in) :: x + integer(kind=int64) :: l + + l = int(len(x), kind=int64) + end function len64 + + function ulen08(x) result(l) + character(len=*,kind=ucs4), intent(in) :: x + integer(kind=int8) :: l + + l = int(len(x), kind=int8) + end function ulen08 + + function ulen16(x) result(l) + character(len=*,kind=ucs4), intent(in) :: x + integer(kind=int16) :: l + + l = int(len(x), kind=int16) + end function ulen16 + + function ulen32(x) result(l) + character(len=*,kind=ucs4), intent(in) :: x + integer(kind=int32) :: l + + l = int(len(x), kind=int32) + end function ulen32 + + function ulen64(x) result(l) + character(len=*,kind=ucs4), intent(in) :: x + integer(kind=int64) :: l + + l = int(len(x), kind=int64) + end function ulen64 + +end program repeat_p -- 2.35.3