From patchwork Fri Feb 12 03:02:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 1439751 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 ozlabs.org (Postfix) with ESMTPS id 4DcJFV54T8z9sRf for ; Fri, 12 Feb 2021 14:02:20 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A531839C5010; Fri, 12 Feb 2021 03:02:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from impout003.msg.chrl.nc.charter.net (impout003aa.msg.chrl.nc.charter.net [47.43.20.27]) by sourceware.org (Postfix) with ESMTPS id E6D8D38618AA; Fri, 12 Feb 2021 03:02:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E6D8D38618AA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=charter.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jvdelisle@charter.net Received: from [192.168.1.9] ([96.41.221.129]) by cmsmtp with ESMTPA id AOihleQ97r76UAOihlTlwB; Fri, 12 Feb 2021 03:02:12 +0000 Authentication-Results: charter.net; none X-Authority-Analysis: v=2.3 cv=dotv9Go4 c=1 sm=1 tr=0 a=07pILqX15KmGv9ZXTMmBNA==:117 a=07pILqX15KmGv9ZXTMmBNA==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=mUirK9RhdQ4hSvJWHl4A:9 a=QEXdDO2ut3YA:10 a=vzWWtDHfITxMyUzM76MA:9 a=De_Ol2h6w80A:10 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=UDnyf2zBuKT2w-IlGP_r:22 To: gfortran From: Jerry DeLisle Subject: [patch, libfortran] PR95647 operator(.eq.) and operator(==) treated differently Message-ID: <7838faa1-6549-c85f-7131-e0a7bd124957@charter.net> Date: Thu, 11 Feb 2021 19:02:10 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 Content-Language: en-US X-CMAE-Envelope: MS4wfIBeKc9NQcbXY+WoihWKg+vLODIqNJ3qtWj00ecpvmhZzUP4qMsjyo9OD01nx6Zl3L/kY9sninXMS12yDhwg1V+73J+E0PhJQ+C1akSfb6kFaUFyCkCI npvwT0arGTjq8RyoUI8QfSz2b1s9aCMIDYYsc1eilnOqudm7AcB8TwLx4Srhzq0oIj1aD65VGLNm2IEBMnYChat0CsjSkSZ7bkg= X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: gcc-patches Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch is another provided from Steve Kargle in the PR report. I have created a test case and regression tested the result. OK for trunk? Regards, Jerry libgfortran: Fix PR95647 by changing the interfaces of operators .eq. and .ne. The FE converts the old school .eq. to ==, and then tracks the ==.  The module starts with == and so it does not properly overload the .eq.  Reversing the interfaces fixes this. 2021-02-11  Steve Kargl libgfortran/ChangeLog:     PR libfortran 95647     * ieee/ieee_arithmetic.F90: Flip interfaces of operators .eq. to     == and .ne. to /= . gcc/testsuite/ChangeLog:     PR libfortran 95647     * gfortran.dg/ieee/ieee_arithmetic: New test. diff --git a/gcc/testsuite/gfortran.dg/ieee/ieee_12.f90 b/gcc/testsuite/gfortran.dg/ieee/ieee_12.f90 new file mode 100644 index 00000000000..139a70142b8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ieee/ieee_12.f90 @@ -0,0 +1,24 @@ +! { dg-do run } +! PR95647 operator(.eq.) and operator(==) treated differently +program test + use, intrinsic :: ieee_arithmetic, only : & +& ieee_class, & +& ieee_class_type, & +& ieee_negative_normal, & +& ieee_positive_normal, & +& operator(.eq.), operator(.ne.) + integer :: good + real(4) r4 + type(ieee_class_type) class1 + good = 0 + r4 = 1.0 + class1 = ieee_class(r4) + if (class1 .eq. ieee_positive_normal) good = good + 1 + if (class1 .ne. ieee_negative_normal) good = good + 1 + r4 = -1.0 + class1 = ieee_class(r4) + if (class1 .eq. ieee_negative_normal) good = good + 1 + if (class1 .ne. ieee_positive_normal) good = good + 1 + if (good /= 4) call abort +end program test + diff --git a/libgfortran/ieee/ieee_arithmetic.F90 b/libgfortran/ieee/ieee_arithmetic.F90 index 55992232ce2..35a16938f8e 100644 --- a/libgfortran/ieee/ieee_arithmetic.F90 +++ b/libgfortran/ieee/ieee_arithmetic.F90 @@ -77,15 +77,16 @@ module IEEE_ARITHMETIC ! Equality operators on the derived types - interface operator (==) + ! Note, the FE overloads .eq. to == and .ne. to /= + interface operator (.eq.) module procedure IEEE_CLASS_TYPE_EQ, IEEE_ROUND_TYPE_EQ end interface - public :: operator(==) + public :: operator(.eq.) - interface operator (/=) + interface operator (.ne.) module procedure IEEE_CLASS_TYPE_NE, IEEE_ROUND_TYPE_NE end interface - public :: operator (/=) + public :: operator (.ne.) ! IEEE_IS_FINITE