aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2009-06-11 07:47:35 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2009-06-11 07:47:35 +0000
commit4ec80803fba73fe898bfc42c57b236c1ca98aaf1 (patch)
tree2d008f94cf845d6abdbd7421b8647fc1e6ef2916 /gcc/fortran
parente8d4f3fcb274af7dc592a5f95ca76da533505920 (diff)
downloadgcc-4ec80803fba73fe898bfc42c57b236c1ca98aaf1.zip
gcc-4ec80803fba73fe898bfc42c57b236c1ca98aaf1.tar.gz
gcc-4ec80803fba73fe898bfc42c57b236c1ca98aaf1.tar.bz2
re PR fortran/38718 (some simplifiers for elemental intrinsics missing; required for init expressions)
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. From-SVN: r148367
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog10
-rw-r--r--gcc/fortran/intrinsic.c11
-rw-r--r--gcc/fortran/intrinsic.h3
-rw-r--r--gcc/fortran/simplify.c48
4 files changed, 68 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 68ad797..1a2f41b 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,13 @@
+2009-06-11 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ 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.
+
2009-06-11 Jakub Jelinek <jakub@redhat.com>
* interface.c (fold_unary): Rename to...
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 014ea11..7bb10ec 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -1845,18 +1845,21 @@ add_functions (void)
add_sym_1 ("is_iostat_end", GFC_ISYM_IS_IOSTAT_END,
CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F2003,
- gfc_check_i, NULL, NULL, i, BT_INTEGER, 0, REQUIRED);
+ gfc_check_i, gfc_simplify_is_iostat_end, NULL,
+ i, BT_INTEGER, 0, REQUIRED);
make_generic ("is_iostat_end", GFC_ISYM_IS_IOSTAT_END, GFC_STD_F2003);
add_sym_1 ("is_iostat_eor", GFC_ISYM_IS_IOSTAT_EOR,
CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F2003,
- gfc_check_i, NULL, NULL, i, BT_INTEGER, 0, REQUIRED);
+ gfc_check_i, gfc_simplify_is_iostat_eor, NULL,
+ i, BT_INTEGER, 0, REQUIRED);
make_generic ("is_iostat_eor", GFC_ISYM_IS_IOSTAT_EOR, GFC_STD_F2003);
- add_sym_1 ("isnan", GFC_ISYM_ISNAN, CLASS_ELEMENTAL, ACTUAL_NO, BT_LOGICAL,
- dl, GFC_STD_GNU, gfc_check_isnan, NULL, NULL,
+ add_sym_1 ("isnan", GFC_ISYM_ISNAN, CLASS_ELEMENTAL, ACTUAL_NO,
+ BT_LOGICAL, dl, GFC_STD_GNU,
+ gfc_check_isnan, gfc_simplify_isnan, NULL,
x, BT_REAL, 0, REQUIRED);
make_generic ("isnan", GFC_ISYM_ISNAN, GFC_STD_GNU);
diff --git a/gcc/fortran/intrinsic.h b/gcc/fortran/intrinsic.h
index 4ae1578..d1bf846 100644
--- a/gcc/fortran/intrinsic.h
+++ b/gcc/fortran/intrinsic.h
@@ -260,6 +260,9 @@ gfc_expr *gfc_simplify_long (gfc_expr *);
gfc_expr *gfc_simplify_ifix (gfc_expr *);
gfc_expr *gfc_simplify_idint (gfc_expr *);
gfc_expr *gfc_simplify_ior (gfc_expr *, gfc_expr *);
+gfc_expr *gfc_simplify_is_iostat_end (gfc_expr *);
+gfc_expr *gfc_simplify_is_iostat_eor (gfc_expr *);
+gfc_expr *gfc_simplify_isnan (gfc_expr *);
gfc_expr *gfc_simplify_ishft (gfc_expr *, gfc_expr *);
gfc_expr *gfc_simplify_ishftc (gfc_expr *, gfc_expr *, gfc_expr *);
gfc_expr *gfc_simplify_kind (gfc_expr *);
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 18ce099..5269e8f 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;