@@ -601,6 +601,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#undef DEC_NAN
#define DEC_NAN (__builtin_nand32 (""))
+/* Signaling NaN in each decimal floating-point type. */
+#undef DEC32_SNAN
+#define DEC32_SNAN (__builtin_nansd32 (""))
+#undef DEC64_SNAN
+#define DEC64_SNAN (__builtin_nansd64 (""))
+#undef DEC128_SNAN
+#define DEC128_SNAN (__builtin_nansd128 (""))
+
#endif /* C2X */
#endif /* __DEC32_MANT_DIG__ */
@@ -12,3 +12,15 @@
#ifdef DEC_NAN
# error "DEC_NAN defined"
#endif
+
+#ifdef DEC32_SNAN
+# error "DEC32_SNAN defined"
+#endif
+
+#ifdef DEC64_SNAN
+# error "DEC64_SNAN defined"
+#endif
+
+#ifdef DEC128_SNAN
+# error "DEC128_SNAN defined"
+#endif
new file mode 100644
@@ -0,0 +1,45 @@
+/* Test DEC*_SNAN macros defined in <float.h> with DFP support. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x" } */
+
+#include <float.h>
+
+#ifndef DEC32_SNAN
+# error "DEC32_SNAN not defined"
+#endif
+
+#ifndef DEC64_SNAN
+# error "DEC64_SNAN not defined"
+#endif
+
+#ifndef DEC128_SNAN
+# error "DEC128_SNAN not defined"
+#endif
+
+volatile _Decimal32 d32 = DEC32_SNAN;
+volatile _Decimal64 d64 = DEC64_SNAN;
+volatile _Decimal128 d128 = DEC128_SNAN;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ (void) _Generic (DEC32_SNAN, _Decimal32 : 0);
+ if (!__builtin_isnan (DEC32_SNAN))
+ abort ();
+ if (!__builtin_isnan (d32))
+ abort ();
+ (void) _Generic (DEC64_SNAN, _Decimal64 : 0);
+ if (!__builtin_isnan (DEC64_SNAN))
+ abort ();
+ if (!__builtin_isnan (d64))
+ abort ();
+ (void) _Generic (DEC128_SNAN, _Decimal128 : 0);
+ if (!__builtin_isnan (DEC128_SNAN))
+ abort ();
+ if (!__builtin_isnan (d128))
+ abort ();
+ exit (0);
+}
new file mode 100644
@@ -0,0 +1,45 @@
+/* Test DEC*_SNAN macros. Test requiring runtime exceptions
+ support. */
+/* { dg-do run } */
+/* { dg-require-effective-target fenv_exceptions_dfp } */
+/* { dg-options "-std=c2x" } */
+
+#include <fenv.h>
+#include <float.h>
+
+volatile _Decimal32 d32 = DEC32_SNAN;
+volatile _Decimal64 d64 = DEC64_SNAN;
+volatile _Decimal128 d128 = DEC128_SNAN;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ feclearexcept (FE_ALL_EXCEPT);
+ d32 += d32;
+ if (!fetestexcept (FE_INVALID))
+ abort ();
+ feclearexcept (FE_ALL_EXCEPT);
+ d32 += d32;
+ if (fetestexcept (FE_INVALID))
+ abort ();
+ feclearexcept (FE_ALL_EXCEPT);
+ d64 += d64;
+ if (!fetestexcept (FE_INVALID))
+ abort ();
+ feclearexcept (FE_ALL_EXCEPT);
+ d64 += d64;
+ if (fetestexcept (FE_INVALID))
+ abort ();
+ feclearexcept (FE_ALL_EXCEPT);
+ d128 += d128;
+ if (!fetestexcept (FE_INVALID))
+ abort ();
+ feclearexcept (FE_ALL_EXCEPT);
+ d128 += d128;
+ if (fetestexcept (FE_INVALID))
+ abort ();
+ exit (0);
+}