From patchwork Wed Sep 14 23:02:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 1226 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2302:b0:79:6ae5:3758 with SMTP id gv2csp978980dyb; Wed, 14 Sep 2022 16:02:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Ss8PzDxd8wBzG7sXdMSITjmqTSUqTWr+6U+76MtU1+JG+d5i9Wb9FXrErsq+otiIgo736 X-Received: by 2002:a05:6402:5cd:b0:446:5965:f4af with SMTP id n13-20020a05640205cd00b004465965f4afmr32302958edx.12.1663196564293; Wed, 14 Sep 2022 16:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663196564; cv=none; d=google.com; s=arc-20160816; b=m+mf5SR/Pao1tR9mdrIeFNMjA5QHZip+sHA1KDQhWuq7MiTUDyofOD8wdlCKAoOOXc rpyFwSyNwm2hXgw4SuZeKuOXdjstFn9RAbWP9yjuQKbNU6fzHVwFUyCPEsJRcfNQ/S0t UvEk5DsIX86KZ5R0w3DEH3gD8qAnLlJLXPjj7v8YckrcxU05ZSLX4Z4XnZhYpekOF76O flXCswLcZya9BzC9QeJ74xlCjFlZeNW9TgO6KeGA45LtwTipTiscv3L0GZVcU0mtMGSl 3zV9bfvNxzWDjmLzcTWIh0z0zFM2CgJqII5cuLoRQdjeU/QY9h9aFeJ59Dr56TpeFycI pdow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:subject:to:from:date:ironport-sdr:dmarc-filter :delivered-to; bh=Tn3Y9LHINv8whOxH3Umh0qKLkILIVYSFVZ8DN7ul44A=; b=qbE2y3l6Wn0gPNRlcZ0r6l8QPuUUy1UcgV1fyI0NzxJsjXR+7cYH0R4BeTH44CzxbM ieA82UQTOKSe5jD6kmMR6GFSEM5aXlBFryHoDPY79vRofL5Q70lklXoTNXl/cqgHYpHO 05IS+IaR2dBMvwamoW+8vU50PfA9M0tfNMfGkD/3udXSbSkxsIwVq4VGn8vIzkXlMVce er1hm6nYh7eePtZ8OrKHrD1cTyNcBwWA/VG+nOYKWofc4Au3JdiqBm4aoSpSL7vfe67/ P01AbBa9DnxNmY3NfbykJ+sB2sRLQUz99PxPtsWvjvnQmTS6YvsSdgnTQK7MhKoN/PVw 1vgA== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id nc36-20020a1709071c2400b00779e71654e6si14818719ejc.56.2022.09.14.16.02.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:02:44 -0700 (PDT) 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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0BB93384D1B4 for ; Wed, 14 Sep 2022 23:02:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 336153857C4B for ; Wed, 14 Sep 2022 23:02:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 336153857C4B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.93,316,1654588800"; d="scan'208";a="85783081" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 14 Sep 2022 15:02:06 -0800 IronPort-SDR: fU4NajMiDcWXI046sAvHBlwLf9fahRyXUOppMZQ8OvR74VxogHoZ+86xZyJ9ZYvuU9L5VqhrUj RbFZGV9rCjWnFz6wbr4FkVAz2Na76ty4ynbYU2uQDTm2NWU0VVurUhvXwK1qQvHYgyS+7v4I2/ 7mjXFEEZgLQJIdeW0hkf8zywLSJDQ9VCJsBNbQQhowa/XCDo2N5hxcUHwnRhIyClt/HqgeUmsf k0YkPYgkobr7DzUeByENP0Dp0XgyikczgU8Y7+bAbfN6z30EJtfzV3VBoNXerR/7sy8yvM4Cwp odY= Date: Wed, 14 Sep 2022 23:02:00 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Subject: float.h: Do not define INFINITY for C2x when infinities not supported Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3117.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, 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.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743988000762873498?= X-GMAIL-MSGID: =?utf-8?q?1743988000762873498?= C2x has changed the rules for defining INFINITY in so it is no longer defined when float does not support infinities, instead of being defined to an expression that overflows at translation time. Thus, make the definition conditional on __FLT_HAS_INFINITY__ (this is already inside a C2x-conditional part of , because previous C standard versions only had this macro in ). Bootstrapped with no regressions for x86_64-pc-linux-gnu. Also did a spot test of the case of no infinities supported by building cc1 for vax-netbsdelf and testing compiling the new c2x-float-11.c test with it. gcc/ * ginclude/float.h (INFINITY): Define only if [__FLT_HAS_INFINITY__]. gcc/testsuite/ * gcc.dg/c2x-float-2.c: Require inff effective-target. * gcc.dg/c2x-float-11.c: New test. diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h index 9d368c4afa5..afe4a712878 100644 --- a/gcc/ginclude/float.h +++ b/gcc/ginclude/float.h @@ -257,9 +257,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define DBL_IS_IEC_60559 __DBL_IS_IEC_60559__ #define LDBL_IS_IEC_60559 __LDBL_IS_IEC_60559__ -/* Infinity in type float, or overflow if infinity not supported. */ +/* Infinity in type float; not defined if infinity not supported. */ +#if __FLT_HAS_INFINITY__ #undef INFINITY #define INFINITY (__builtin_inff ()) +#endif /* Quiet NaN, if supported for float. */ #if __FLT_HAS_QUIET_NAN__ diff --git a/gcc/testsuite/gcc.dg/c2x-float-11.c b/gcc/testsuite/gcc.dg/c2x-float-11.c new file mode 100644 index 00000000000..0e2f3c0c97a --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-float-11.c @@ -0,0 +1,9 @@ +/* Test INFINITY macro. Test when infinities not supported. */ +/* { dg-do compile { target { ! inff } } } */ +/* { dg-options "-std=c2x" } */ + +#include + +#ifdef INFINITY +#error "INFINITY defined" +#endif diff --git a/gcc/testsuite/gcc.dg/c2x-float-2.c b/gcc/testsuite/gcc.dg/c2x-float-2.c index 4f669fd39bc..61a77f6f2db 100644 --- a/gcc/testsuite/gcc.dg/c2x-float-2.c +++ b/gcc/testsuite/gcc.dg/c2x-float-2.c @@ -1,8 +1,8 @@ -/* Test INFINITY macro. Generic test even if infinities not - supported. */ +/* Test INFINITY macro. Generic test. */ /* { dg-do run } */ /* { dg-options "-std=c2x -w" } */ /* { dg-add-options ieee } */ +/* { dg-require-effective-target inff } */ #include