From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1105) id 9F2C43858419; Thu, 15 Sep 2022 20:11:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F2C43858419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663272689; bh=ahofi0K/+naWWrUy1gSDxrsKH0rU2I2vm7B3qajWMhc=; h=From:To:Subject:Date:From; b=lO6A5zVk3Bbu0JjUJyjxfLbmj4y/qYU8tUh4k+6AFMdNaB8/SKmeUZGAV6vTezFlo E9ps4t2OiAR4sGlmsPL1LCApuKeWoy9KPiotlUTGAPf9jhW22Ss9yl0zJkvW8g8JrM HOiFjWMRE/lJyVVocOtQ2zy9WwqXp01gVdfBWZk8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Joseph Myers To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2689] float.h: Do not define INFINITY for C2x when infinities not supported X-Act-Checkin: gcc X-Git-Author: Joseph Myers X-Git-Refname: refs/heads/master X-Git-Oldrev: ecbdfa8b314e2c17da17511b86371f552bffd441 X-Git-Newrev: 6248f4ff67502c88d92f55fa5ea5996937220e5c Message-Id: <20220915201129.9F2C43858419@sourceware.org> Date: Thu, 15 Sep 2022 20:11:28 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6248f4ff67502c88d92f55fa5ea5996937220e5c commit r13-2689-g6248f4ff67502c88d92f55fa5ea5996937220e5c Author: Joseph Myers Date: Thu Sep 15 20:10:42 2022 +0000 float.h: Do not define INFINITY for C2x when infinities not supported 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: --- gcc/ginclude/float.h | 4 +++- gcc/testsuite/gcc.dg/c2x-float-11.c | 9 +++++++++ gcc/testsuite/gcc.dg/c2x-float-2.c | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) 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