+ if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init)))
+ return false;
+ if ((REAL_VALUE_ISINF (TREE_REAL_CST (init))
+ && MODE_HAS_INFINITIES (TYPE_MODE (type)))
+ || (REAL_VALUE_ISNAN (TREE_REAL_CST (init))
+ && MODE_HAS_NANS (TYPE_MODE (type))))
+ return true;
+ if (DECIMAL_FLOAT_TYPE_P (type)
+ && !DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init)))
+ {
+ /* This is valid if the real number represented by the
+ initializer can be exactly represented in the decimal
+ type. Compare the values using MPFR. */
+ REAL_VALUE_TYPE t;
+ real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
+ mpfr_t bin_val, dec_val;
+ mpfr_init2 (bin_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
+ mpfr_init2 (dec_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
+ mpfr_from_real (bin_val, &TREE_REAL_CST (init), MPFR_RNDN);
+ char string[256];
+ real_to_decimal (string, &t, sizeof string, 0, 1);
+ bool res = (mpfr_strtofr (dec_val, string, NULL, 10, MPFR_RNDN) == 0
+ && mpfr_equal_p (bin_val, dec_val));
+ mpfr_clear (bin_val);
+ mpfr_clear (dec_val);
+ return res;
+ }