summaryrefslogtreecommitdiff
path: root/gcc/fortran/simplify.c
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-11 07:47:35 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-11 07:47:35 +0000
commit96098ab0564305340a17a5bc18f80ef25455a9fc (patch)
tree2d008f94cf845d6abdbd7421b8647fc1e6ef2916 /gcc/fortran/simplify.c
parent9e6639e675e291c5fa913408ffe9916036fb2524 (diff)
downloadgcc-96098ab0564305340a17a5bc18f80ef25455a9fc.tar.gz
PR fortran/38718
* intrinsic.c (add_functions): Add simplifiers for ISNAN, IS_IOSTAT_END and IS_IOSTAT_EOR. * intrinsic.h (gfc_simplify_is_iostat_end, * gfc_simplify_is_iostat_eor, gfc_simplify_isnan): New prototypes. * intrinsic.c (gfc_simplify_is_iostat_end, * gfc_simplify_is_iostat_eor, gfc_simplify_isnan): New functions. * gfortran.dg/is_iostat_end_eor_2.f90: New test. * gfortran.dg/nan_5.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148367 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r--gcc/fortran/simplify.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 18ce099ae77..5269e8f206e 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -2626,6 +2626,54 @@ gfc_simplify_ior (gfc_expr *x, gfc_expr *y)
gfc_expr *
+gfc_simplify_is_iostat_end (gfc_expr *x)
+{
+ gfc_expr *result;
+
+ if (x->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ result = gfc_constant_result (BT_LOGICAL, gfc_default_logical_kind,
+ &x->where);
+ result->value.logical = (mpz_cmp_si (x->value.integer, LIBERROR_END) == 0);
+
+ return result;
+}
+
+
+gfc_expr *
+gfc_simplify_is_iostat_eor (gfc_expr *x)
+{
+ gfc_expr *result;
+
+ if (x->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ result = gfc_constant_result (BT_LOGICAL, gfc_default_logical_kind,
+ &x->where);
+ result->value.logical = (mpz_cmp_si (x->value.integer, LIBERROR_EOR) == 0);
+
+ return result;
+}
+
+
+gfc_expr *
+gfc_simplify_isnan (gfc_expr *x)
+{
+ gfc_expr *result;
+
+ if (x->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ result = gfc_constant_result (BT_LOGICAL, gfc_default_logical_kind,
+ &x->where);
+ result->value.logical = mpfr_nan_p (x->value.real);
+
+ return result;
+}
+
+
+gfc_expr *
gfc_simplify_ishft (gfc_expr *e, gfc_expr *s)
{
gfc_expr *result;