@item inf
Target supports floating point infinite (@code{inf}) for type
@code{double}.
+
+@item inff
+Target supports floating point infinite (@code{inf}) for type
+@code{float}.
@end table
@subsubsection Fortran-specific attributes
#define DBL_NORM_MAX __DBL_NORM_MAX__
#define LDBL_NORM_MAX __LDBL_NORM_MAX__
+/* Infinity in type float, or overflow if infinity not supported. */
+#undef INFINITY
+#define INFINITY (__builtin_inff ())
+
+/* Quiet NaN, if supported for float. */
+#if __FLT_HAS_QUIET_NAN__
+#undef NAN
+#define NAN (__builtin_nanf (""))
+#endif
+
+/* Signaling NaN, if supported for each type. All formats supported
+ by GCC support either both quiet and signaling NaNs, or neither
+ kind of NaN. */
+#if __FLT_HAS_QUIET_NAN__
+#undef FLT_SNAN
+#define FLT_SNAN (__builtin_nansf (""))
+#endif
+#if __DBL_HAS_QUIET_NAN__
+#undef DBL_SNAN
+#define DBL_SNAN (__builtin_nans (""))
+#endif
+#if __LDBL_HAS_QUIET_NAN__
+#undef LDBL_SNAN
+#define LDBL_SNAN (__builtin_nansl (""))
+#endif
+
#endif /* C2X */
#ifdef __STDC_WANT_IEC_60559_BFP_EXT__
#define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__
#undef FLT16_TRUE_MIN
#define FLT16_TRUE_MIN __FLT16_DENORM_MIN__
+#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
+#undef FLT16_SNAN
+#define FLT16_SNAN (__builtin_nansf16 (""))
+#endif /* C2X */
#endif /* __FLT16_MANT_DIG__. */
#ifdef __FLT32_MANT_DIG__
#define FLT32_DECIMAL_DIG __FLT32_DECIMAL_DIG__
#undef FLT32_TRUE_MIN
#define FLT32_TRUE_MIN __FLT32_DENORM_MIN__
+#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
+#undef FLT32_SNAN
+#define FLT32_SNAN (__builtin_nansf32 (""))
+#endif /* C2X */
#endif /* __FLT32_MANT_DIG__. */
#ifdef __FLT64_MANT_DIG__
#define FLT64_DECIMAL_DIG __FLT64_DECIMAL_DIG__
#undef FLT64_TRUE_MIN
#define FLT64_TRUE_MIN __FLT64_DENORM_MIN__
+#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
+#undef FLT64_SNAN
+#define FLT64_SNAN (__builtin_nansf64 (""))
+#endif /* C2X */
#endif /* __FLT64_MANT_DIG__. */
#ifdef __FLT128_MANT_DIG__
#define FLT128_DECIMAL_DIG __FLT128_DECIMAL_DIG__
#undef FLT128_TRUE_MIN
#define FLT128_TRUE_MIN __FLT128_DENORM_MIN__
+#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
+#undef FLT128_SNAN
+#define FLT128_SNAN (__builtin_nansf128 (""))
+#endif /* C2X */
#endif /* __FLT128_MANT_DIG__. */
#ifdef __FLT32X_MANT_DIG__
#define FLT32X_DECIMAL_DIG __FLT32X_DECIMAL_DIG__
#undef FLT32X_TRUE_MIN
#define FLT32X_TRUE_MIN __FLT32X_DENORM_MIN__
+#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
+#undef FLT32X_SNAN
+#define FLT32X_SNAN (__builtin_nansf32x (""))
+#endif /* C2X */
#endif /* __FLT32X_MANT_DIG__. */
#ifdef __FLT64X_MANT_DIG__
#define FLT64X_DECIMAL_DIG __FLT64X_DECIMAL_DIG__
#undef FLT64X_TRUE_MIN
#define FLT64X_TRUE_MIN __FLT64X_DENORM_MIN__
+#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
+#undef FLT64X_SNAN
+#define FLT64X_SNAN (__builtin_nansf64x (""))
+#endif /* C2X */
#endif /* __FLT64X_MANT_DIG__. */
#ifdef __FLT128X_MANT_DIG__
#define FLT128X_DECIMAL_DIG __FLT128X_DECIMAL_DIG__
#undef FLT128X_TRUE_MIN
#define FLT128X_TRUE_MIN __FLT128X_DENORM_MIN__
+#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
+#undef FLT128X_SNAN
+#define FLT128X_SNAN (__builtin_nansf128x (""))
+#endif /* C2X */
#endif /* __FLT128X_MANT_DIG__. */
#endif /* __STDC_WANT_IEC_60559_TYPES_EXT__. */
#endif /* __STDC_WANT_IEC_60559_DFP_EXT__ || C2X. */
+#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
+
+/* Infinity in type _Decimal32. */
+#undef DEC_INFINITY
+#define DEC_INFINITY (__builtin_infd32 ())
+
+/* Quiet NaN in type _Decimal32. */
+#undef DEC_NAN
+#define DEC_NAN (__builtin_nand32 (""))
+
+#endif /* C2X */
+
#endif /* __DEC32_MANT_DIG__ */
#endif /* _FLOAT_H___ */
--- /dev/null
+/* Test infinity and NaN macros not defined for C11. */
+/* { dg-do preprocess } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+#include <float.h>
+
+#ifdef INFINITY
+#error "INFINITY defined"
+#endif
+
+#ifdef NAN
+#error "NAN defined"
+#endif
+
+#ifdef FLT_SNAN
+#error "FLT_SNAN defined"
+#endif
+
+#ifdef DBL_SNAN
+#error "DBL_SNAN defined"
+#endif
+
+#ifdef LDBL_SNAN
+#error "LDBL_SNAN defined"
+#endif
--- /dev/null
+/* Test sNaN macros for _FloatN and _FloatNx not defined for C11 with
+ __STDC_WANT_IEC_60559_TYPES_EXT__. */
+/* { dg-do preprocess } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+#define __STDC_WANT_IEC_60559_TYPES_EXT__
+#include <float.h>
+
+#ifdef FLT16_SNAN
+#error "FLT16_SNAN defined"
+#endif
+
+#ifdef FLT32_SNAN
+#error "FLT32_SNAN defined"
+#endif
+
+#ifdef FLT64_SNAN
+#error "FLT64_SNAN defined"
+#endif
+
+#ifdef FLT128_SNAN
+#error "FLT128_SNAN defined"
+#endif
+
+#ifdef FLT32X_SNAN
+#error "FLT32X_SNAN defined"
+#endif
+
+#ifdef FLT64X_SNAN
+#error "FLT64X_SNAN defined"
+#endif
+
+#ifdef FLT128X_SNAN
+#error "FLT128X_SNAN defined"
+#endif
--- /dev/null
+/* Test DFP macros not defined in <float.h> for C11. Infinity and NaN
+ macros. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11" } */
+
+#include "c2x-float-no-dfp-3.c"
--- /dev/null
+/* Test INFINITY macro. Generic test even if infinities not
+ supported. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -w" } */
+/* { dg-add-options ieee } */
+
+#include <float.h>
+
+#ifndef INFINITY
+#error "INFINITY undefined"
+#endif
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ (void) _Generic (INFINITY, float : 0);
+ if (!(INFINITY >= FLT_MAX))
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* Test INFINITY macro. Test when infinities supported. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target inff } */
+
+#include <float.h>
+
+#ifndef INFINITY
+#error "INFINITY undefined"
+#endif
+
+volatile float f = INFINITY;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ (void) _Generic (INFINITY, float : 0);
+ if (!(INFINITY > FLT_MAX))
+ abort ();
+ if (!(f > FLT_MAX))
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* Test NAN macro. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+/* { dg-add-options ieee } */
+
+#include <float.h>
+
+/* This should be defined if and only if quiet NaNs are supported for
+ type float. If the testsuite gains effective-target support for
+ targets not supporting NaNs, or not supporting them for all types,
+ this test should be split into versions for targets with and
+ without NaNs for float. */
+#ifndef NAN
+#error "NAN undefined"
+#endif
+
+volatile float f = NAN;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ (void) _Generic (NAN, float : 0);
+ if (!__builtin_isnan (NAN))
+ abort ();
+ if (!__builtin_isnan (f))
+ abort ();
+ if (!__builtin_isnan (f + f))
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* Test NAN macro. Runtime exceptions test, to verify NaN is quiet
+ not signaling. */
+/* { dg-do run } */
+/* { dg-require-effective-target fenv_exceptions } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+/* { dg-add-options ieee } */
+
+#include <fenv.h>
+#include <float.h>
+
+/* This should be defined if and only if quiet NaNs are supported for
+ type float. If the testsuite gains effective-target support for
+ targets not supporting NaNs, or not supporting them for all types,
+ this test should only be run for targets supporting quiet NaNs for
+ float. */
+#ifndef NAN
+#error "NAN undefined"
+#endif
+
+volatile float f = NAN;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ f += f;
+ if (fetestexcept (FE_INVALID))
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* Test SNAN macros. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -pedantic-errors -fsignaling-nans" } */
+/* { dg-add-options ieee } */
+
+#include <float.h>
+
+/* These should be defined if and only if signaling NaNs are supported
+ for the given types. If the testsuite gains effective-target
+ support for targets not supporting signaling NaNs, or not
+ supporting them for all types, this test should be made
+ appropriately conditional. */
+#ifndef FLT_SNAN
+#error "FLT_SNAN undefined"
+#endif
+#ifndef DBL_SNAN
+#error "DBL_SNAN undefined"
+#endif
+#ifndef LDBL_SNAN
+#error "LDBL_SNAN undefined"
+#endif
+
+volatile float f = FLT_SNAN;
+volatile double d = DBL_SNAN;
+volatile long double ld = LDBL_SNAN;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ (void) _Generic (FLT_SNAN, float : 0);
+ (void) _Generic (DBL_SNAN, double : 0);
+ (void) _Generic (LDBL_SNAN, long double : 0);
+ if (!__builtin_isnan (FLT_SNAN))
+ abort ();
+ if (!__builtin_isnan (f))
+ abort ();
+ if (!__builtin_isnan (DBL_SNAN))
+ abort ();
+ if (!__builtin_isnan (d))
+ abort ();
+ if (!__builtin_isnan (LDBL_SNAN))
+ abort ();
+ if (!__builtin_isnan (ld))
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* Test SNAN macros. Runtime exceptions test, to verify NaN is
+ signaling. */
+/* { dg-do run } */
+/* { dg-require-effective-target fenv_exceptions } */
+/* { dg-options "-std=c2x -pedantic-errors -fsignaling-nans" } */
+/* { dg-add-options ieee } */
+
+#include <fenv.h>
+#include <float.h>
+
+/* These should be defined if and only if signaling NaNs are supported
+ for the given types. If the testsuite gains effective-target
+ support for targets not supporting signaling NaNs, or not
+ supporting them for all types, this test should be made
+ appropriately conditional. */
+#ifndef FLT_SNAN
+#error "FLT_SNAN undefined"
+#endif
+#ifndef DBL_SNAN
+#error "DBL_SNAN undefined"
+#endif
+#ifndef LDBL_SNAN
+#error "LDBL_SNAN undefined"
+#endif
+
+volatile float f = FLT_SNAN;
+volatile double d = DBL_SNAN;
+volatile long double ld = LDBL_SNAN;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ feclearexcept (FE_ALL_EXCEPT);
+ f += f;
+ if (!fetestexcept (FE_INVALID))
+ abort ();
+ feclearexcept (FE_ALL_EXCEPT);
+ d += d;
+ if (!fetestexcept (FE_INVALID))
+ abort ();
+ feclearexcept (FE_ALL_EXCEPT);
+ ld += ld;
+ if (!fetestexcept (FE_INVALID))
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* Test including <math.h> then <float.h> does not result in errors
+ from duplicate NAN and INFINITY macros. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+#include <math.h>
+#include <float.h>
--- /dev/null
+/* Test including <float.h> then <math.h> does not result in errors
+ from duplicate NAN and INFINITY macros. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+#include <float.h>
+#include <math.h>
--- /dev/null
+/* Test DFP macros not defined in <float.h> if no DFP support.
+ Infinity and NaN macros. */
+/* { dg-do compile { target { ! dfp } } } */
+/* { dg-options "-std=c2x" } */
+
+#include <float.h>
+
+#ifdef DEC_INFINITY
+# error "DEC_INFINITY defined"
+#endif
+
+#ifdef DEC_NAN
+# error "DEC_NAN defined"
+#endif
--- /dev/null
+/* Test DFP macros not defined in <float.h> if no DFP support.
+ Infinity and NaN macros. Test with feature test macros
+ defined. */
+/* { dg-do compile { target { ! dfp } } } */
+/* { dg-options "-std=c2x" } */
+
+#define __STDC_WANT_DEC_FP__
+#define __STDC_WANT_IEC_60559_DFP_EXT__
+
+#include "c2x-float-no-dfp-3.c"
--- /dev/null
+/* Test DEC_INFINITY defined in <float.h> with DFP support. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x" } */
+
+#include <float.h>
+
+#ifndef DEC_INFINITY
+# error "DEC_INFINITY not defined"
+#endif
+
+volatile _Decimal32 d = DEC_INFINITY;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ (void) _Generic (DEC_INFINITY, _Decimal32 : 0);
+ if (!(DEC_INFINITY > DEC32_MAX))
+ abort ();
+ if (!(d > DEC32_MAX))
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* Test DEC_NAN defined in <float.h> with DFP support. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x" } */
+
+#include <float.h>
+
+#ifndef DEC_NAN
+# error "DEC_NAN not defined"
+#endif
+
+volatile _Decimal32 d = DEC_NAN;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ (void) _Generic (DEC_NAN, _Decimal32 : 0);
+ if (!__builtin_isnan (DEC_NAN))
+ abort ();
+ if (!__builtin_isnan (d))
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* Test DEC_NAN macro. Runtime exceptions test, to verify NaN is
+ quiet not signaling. (This would only actually fail for a
+ signaling NaN in the hardware DFP case, because the software DFP
+ support in libgcc does not integrate with hardware exceptions.) */
+/* { dg-do run } */
+/* { dg-require-effective-target fenv_exceptions } */
+/* { dg-options "-std=c2x" } */
+
+#include <fenv.h>
+#include <float.h>
+
+#ifndef DEC_NAN
+# error "DEC_NAN not defined"
+#endif
+
+volatile _Decimal32 d = DEC_NAN;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ d += d;
+ if (fetestexcept (FE_INVALID))
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* Test _Float128 NaNs in <float.h>. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -fsignaling-nans" } */
+/* { dg-add-options float128 } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float128_runtime } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#define WIDTH 128
+#define EXT 0
+#include "floatn-nan-floath.h"
--- /dev/null
+/* Test _Float128x NaNs in <float.h>. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -fsignaling-nans" } */
+/* { dg-add-options float128x } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float128x_runtime } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#define WIDTH 128
+#define EXT 1
+#include "floatn-nan-floath.h"
--- /dev/null
+/* Test _Float16 NaNs in <float.h>. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -fsignaling-nans" } */
+/* { dg-add-options float16 } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float16_runtime } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#define WIDTH 16
+#define EXT 0
+#include "floatn-nan-floath.h"
--- /dev/null
+/* Test _Float32 NaNs in <float.h>. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -fsignaling-nans" } */
+/* { dg-add-options float32 } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float32_runtime } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#define WIDTH 32
+#define EXT 0
+#include "floatn-nan-floath.h"
--- /dev/null
+/* Test _Float32x NaNs in <float.h>. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -fsignaling-nans" } */
+/* { dg-add-options float32x } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float32x_runtime } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#define WIDTH 32
+#define EXT 1
+#include "floatn-nan-floath.h"
--- /dev/null
+/* Test _Float64 NaNs in <float.h>. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -fsignaling-nans" } */
+/* { dg-add-options float64 } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float64_runtime } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#define WIDTH 64
+#define EXT 0
+#include "floatn-nan-floath.h"
--- /dev/null
+/* Test _Float64x NaNs in <float.h>. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -fsignaling-nans" } */
+/* { dg-add-options float64x } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float64x_runtime } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#define WIDTH 64
+#define EXT 1
+#include "floatn-nan-floath.h"
--- /dev/null
+/* Tests for _FloatN / _FloatNx types: compile and execution tests for
+ NaNs, SNAN macros in <float.h>. Before including this file, define
+ WIDTH as the value N; define EXT to 1 for _FloatNx and 0 for
+ _FloatN. */
+
+#define CONCATX(X, Y) X ## Y
+#define CONCAT(X, Y) CONCATX (X, Y)
+#define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z)
+#define CONCAT4(W, X, Y, Z) CONCAT (CONCAT (CONCAT (W, X), Y), Z)
+
+#if EXT
+# define TYPE CONCAT3 (_Float, WIDTH, x)
+# define SNAN CONCAT3 (FLT, WIDTH, X_SNAN)
+#else
+# define TYPE CONCAT (_Float, WIDTH)
+# define SNAN CONCAT3 (FLT, WIDTH, _SNAN)
+#endif
+
+#define __STDC_WANT_IEC_60559_TYPES_EXT__
+#include <fenv.h>
+#include <float.h>
+
+extern void exit (int);
+extern void abort (void);
+
+volatile TYPE nans_cst = SNAN;
+
+int
+main (void)
+{
+ volatile TYPE r;
+ r = nans_cst + nans_cst;
+ if (!fetestexcept (FE_INVALID))
+ abort ();
+ exit (0);
+}
}]
}
+# Return 1 if target supports floating point "infinite" for float.
+proc check_effective_target_inff { } {
+ return [check_no_compiler_messages supports_inff assembly {
+ const float pinf = __builtin_inff ();
+ }]
+}
+
# Return 1 if the target supports ARMv8.3 Adv.SIMD Complex instructions
# instructions, 0 otherwise. The test is valid for ARM and for AArch64.
# Record the command line options needed.