| Index: gcc/gcc/fortran/trans-const.c
|
| diff --git a/gcc/gcc/fortran/trans-const.c b/gcc/gcc/fortran/trans-const.c
|
| index e4e04f91f47ee8c8bdb1a298928165168aa41fd8..74520889d7e071519e42fdf66f0ca9b7477baa0d 100644
|
| --- a/gcc/gcc/fortran/trans-const.c
|
| +++ b/gcc/gcc/fortran/trans-const.c
|
| @@ -176,7 +176,7 @@ gfc_conv_string_init (tree length, gfc_expr * expr)
|
| void
|
| gfc_conv_const_charlen (gfc_charlen * cl)
|
| {
|
| - if (cl->backend_decl)
|
| + if (!cl || cl->backend_decl)
|
| return;
|
|
|
| if (cl->length && cl->length->expr_type == EXPR_CONSTANT)
|
| @@ -218,7 +218,7 @@ gfc_conv_tree_to_mpz (mpz_t i, tree source)
|
| /* Converts a real constant into backend form. */
|
|
|
| tree
|
| -gfc_conv_mpfr_to_tree (mpfr_t f, int kind)
|
| +gfc_conv_mpfr_to_tree (mpfr_t f, int kind, int is_snan)
|
| {
|
| tree type;
|
| int n;
|
| @@ -228,7 +228,11 @@ gfc_conv_mpfr_to_tree (mpfr_t f, int kind)
|
| gcc_assert (gfc_real_kinds[n].radix == 2);
|
|
|
| type = gfc_get_real_type (kind);
|
| - real_from_mpfr (&real, f, type, GFC_RND_MODE);
|
| + if (mpfr_nan_p (f) && is_snan)
|
| + real_from_string (&real, "SNaN");
|
| + else
|
| + real_from_mpfr (&real, f, type, GFC_RND_MODE);
|
| +
|
| return build_real (type, real);
|
| }
|
|
|
| @@ -277,7 +281,7 @@ gfc_conv_constant_to_tree (gfc_expr * expr)
|
| gfc_build_string_const (expr->representation.length,
|
| expr->representation.string));
|
| else
|
| - return gfc_conv_mpfr_to_tree (expr->value.real, expr->ts.kind);
|
| + return gfc_conv_mpfr_to_tree (expr->value.real, expr->ts.kind, expr->is_snan);
|
|
|
| case BT_LOGICAL:
|
| if (expr->representation.string)
|
| @@ -303,10 +307,10 @@ gfc_conv_constant_to_tree (gfc_expr * expr)
|
| expr->representation.string));
|
| else
|
| {
|
| - tree real = gfc_conv_mpfr_to_tree (expr->value.complex.r,
|
| - expr->ts.kind);
|
| - tree imag = gfc_conv_mpfr_to_tree (expr->value.complex.i,
|
| - expr->ts.kind);
|
| + tree real = gfc_conv_mpfr_to_tree (mpc_realref (expr->value.complex),
|
| + expr->ts.kind, expr->is_snan);
|
| + tree imag = gfc_conv_mpfr_to_tree (mpc_imagref (expr->value.complex),
|
| + expr->ts.kind, expr->is_snan);
|
|
|
| return build_complex (gfc_typenode_for_spec (&expr->ts),
|
| real, imag);
|
| @@ -338,8 +342,8 @@ gfc_conv_constant (gfc_se * se, gfc_expr * expr)
|
| /* We may be receiving an expression for C_NULL_PTR or C_NULL_FUNPTR. If
|
| so, the expr_type will not yet be an EXPR_CONSTANT. We need to make
|
| it so here. */
|
| - if (expr->ts.type == BT_DERIVED && expr->ts.derived
|
| - && expr->ts.derived->attr.is_iso_c)
|
| + if (expr->ts.type == BT_DERIVED && expr->ts.u.derived
|
| + && expr->ts.u.derived->attr.is_iso_c)
|
| {
|
| if (expr->symtree->n.sym->intmod_sym_id == ISOCBINDING_NULL_PTR
|
| || expr->symtree->n.sym->intmod_sym_id == ISOCBINDING_NULL_FUNPTR)
|
|
|