From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Type: text/plain; charset="US-ASCII" 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 List-Id: 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 -- Joseph S. Myers joseph@codesourcery.com