From patchwork Fri Nov 1 09:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 100005 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11F163858C31 for ; Fri, 1 Nov 2024 09:01:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cc-smtpout1.netcologne.de (cc-smtpout1.netcologne.de [IPv6:2001:4dd0:100:1062:25:2:0:1]) by sourceware.org (Postfix) with ESMTPS id D46873858C62; Fri, 1 Nov 2024 09:00:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D46873858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=netcologne.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=netcologne.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D46873858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4dd0:100:1062:25:2:0:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730451636; cv=none; b=M++07HwZkCnXb15CmV/Jc3MRevvdX3aUyuFveu40AZBOF4zjGzfwruGlb13XqoqeNmdv7eC4blESk4P4a4cmCOfIv/aLIqwiPaJrEOI20UTykzuSaAuNC4Ark6ymT7k+t09XEh1H5+Vv8NPDkVN5Sm9wc6DxQd3OlCu6BLMM3Ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730451636; c=relaxed/simple; bh=7vuOlEtAwNhayto2BTUxUI1xhBpBSFCBXqatJTm/uYw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=YHsDPFDPv94JsGYj1D6kBDfN6TV0R4aI0gBBBJSs4ZcnXR2XpziGa5MrgA73duU0ojgrojwIQ9FPk8K+Wgck1CB2tI98pv1tvqFnKb/XN6ujbT0MjH1UGnqVdNUC0jbGDxEDUEZKfvXKMfYdQkkXVjCKA5B1P7jt+STIMRdqIgw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 780F939B35; Fri, 1 Nov 2024 10:00:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1730451631; bh=7vuOlEtAwNhayto2BTUxUI1xhBpBSFCBXqatJTm/uYw=; h=Message-ID:Date:To:From:Subject:From; b=elbdazHgw615t4w6wWy5VtoQlwvyQWHLH63glZYM48xN8SAuOKvs4Oa77zcUJLUNH I66nxSxMsc3hSKCO8sV8FbAwQ+6+DO4r+fswIpyVApD2wUd60FKR1MKgJfjoTZfHav mZUHZQk0/1WqKrWmNzQpn2m7A2/v4VbixcU1sUYX5VE98O3MRSYZ51D/XTQlUsrhaz MGruskR9IePRkhg8HLIt9LinX2spLtwiJU2MvhvNacq57yR/0VCYLgB79QSCq8UNmt E3/V/dtlv1pZb/aSm6JrX82zUg78nvFXEEo1LuKkrmB5qL8LAGKN0gtwTs/oQjYIe+ fJ2WQ1Naxbg3w== Received: from [IPV6:2001:4dd7:5cd8:0:c1d0:4985:906a:7f1c] (2001-4dd7-5cd8-0-c1d0-4985-906a-7f1c.ipv6dyn.netcologne.de [IPv6:2001:4dd7:5cd8:0:c1d0:4985:906a:7f1c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA id 4573711DA1; Fri, 1 Nov 2024 10:00:29 +0100 (CET) Message-ID: <6e6edac1-cf23-4719-bc73-ff27da9822f4@netcologne.de> Date: Fri, 1 Nov 2024 10:00:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US, de-DE To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, Fortran] Fix -mod(unsigned, unsigned) X-NetCologne-Spam: L X-Rspamd-Queue-Id: 4573711DA1 X-Rspamd-Action: no action X-Spamd-Bar: / X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org Hello world, during testing, I noticed that parameters of the form - mod(u1,u2) were rejected with an unknown type. The fix is straightforward, but required an adjustment to another test case. Regression-tested. OK for trunk? gcc/fortran/ChangeLog: * resolve.cc (resolve_operator): Also handle BT_UNSIGNED. gcc/testsuite/ChangeLog: * gfortran.dg/unsigned_38.f90: Add -pedantic and adjust error message. * gfortran.dg/unsigned_40.f90: New test. diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 565d4aa5fe9..535fa08b13b 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -4253,7 +4253,8 @@ resolve_operator (gfc_expr *e) case INTRINSIC_UMINUS: if (op1->ts.type == BT_INTEGER || op1->ts.type == BT_REAL - || op1->ts.type == BT_COMPLEX) + || op1->ts.type == BT_COMPLEX + || op1->ts.type == BT_UNSIGNED) { e->ts = op1->ts; break; diff --git a/gcc/testsuite/gfortran.dg/unsigned_38.f90 b/gcc/testsuite/gfortran.dg/unsigned_38.f90 index d549483b269..ac1cfb33aac 100644 --- a/gcc/testsuite/gfortran.dg/unsigned_38.f90 +++ b/gcc/testsuite/gfortran.dg/unsigned_38.f90 @@ -1,6 +1,6 @@ ! { dg-do compile } -! { dg-options "-funsigned" } +! { dg-options "-funsigned -pedantic" } program main unsigned, parameter :: u = 7u - print *,mod(-(u+1u),u) ! { dg-error "Operand of unary numeric operator" } + print *,mod(-(u+1u),u) ! { dg-error "Negation of unsigned expression" } end program main diff --git a/gcc/testsuite/gfortran.dg/unsigned_40.f90 b/gcc/testsuite/gfortran.dg/unsigned_40.f90 new file mode 100644 index 00000000000..129fc883f17 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unsigned_40.f90 @@ -0,0 +1,19 @@ +! { dg-do run } +! { dg-options "-funsigned" } +program memain + use iso_fortran_env, only : uint8 + call test1 + call test2 +contains + subroutine test1 + unsigned(uint8) :: nface, nmax + nface = 12u_1 + nmax = - mod(-nface+1u,nface) + if (nmax /= 251u_1) error stop 1 + end subroutine test1 + subroutine test2 + unsigned(uint8), parameter :: nface = 12u_1 + unsigned(uint8), parameter :: nmax = - mod(-nface+1u,nface) + if (nmax /= 251u_1) error stop 11 + end subroutine test2 +end program memain