aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/arith.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2005-06-01 19:17:37 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2005-06-01 19:17:37 +0000
commitc3a29423de8cfb7e2b5642b9d44eb21e4b286aec (patch)
treeaca5715d2e2402e23f8d6fcb8a69bdb7516dab2e /gcc/fortran/arith.c
parentcdeee6d28017c9c881d2395645b3314fa575e59b (diff)
downloadgcc-c3a29423de8cfb7e2b5642b9d44eb21e4b286aec.zip
gcc-c3a29423de8cfb7e2b5642b9d44eb21e4b286aec.tar.gz
gcc-c3a29423de8cfb7e2b5642b9d44eb21e4b286aec.tar.bz2
intrinsic.c (add_conv): No longer take a "simplify" argument as its always gfc_convert_constant...
* intrinsic.c (add_conv): No longer take a "simplify" argument as its always gfc_convert_constant, instead take a "standard" argument. (add_conversions): Change all existing calls of add_conv to pass GFC_STD_F77 as appropriate. Additionally, if we're allowing GNU extensions support integer-logical and logical-integer conversions. (gfc_convert_type_warn): Warn about use the use of these conversions as a extension when appropriate, i.e. with -pedantic. * simplify.c (gfc_convert_constant): Add support for integer to logical and logical to integer conversions, using gfc_int2log and gfc_log2int. * arith.c (gfc_log2int, gfc_int2log): New functions. * arith.h (gfc_log2int, gfc_int2log): Prototype here. * gfortran.texi: Document this new GNU extension. * gfortran.dg/logint-1.f: New test case. * gfortran.dg/logint-2.f: Likewise. * gfortran.dg/logint-3.f: Likewise. From-SVN: r100461
Diffstat (limited to 'gcc/fortran/arith.c')
-rw-r--r--gcc/fortran/arith.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c
index 88b6c36..684ae7b 100644
--- a/gcc/fortran/arith.c
+++ b/gcc/fortran/arith.c
@@ -2191,3 +2191,26 @@ gfc_log2log (gfc_expr * src, int kind)
return result;
}
+
+/* Convert logical to integer. */
+
+gfc_expr *
+gfc_log2int (gfc_expr *src, int kind)
+{
+ gfc_expr *result;
+ result = gfc_constant_result (BT_INTEGER, kind, &src->where);
+ mpz_set_si (result->value.integer, src->value.logical);
+ return result;
+}
+
+/* Convert integer to logical. */
+
+gfc_expr *
+gfc_int2log (gfc_expr *src, int kind)
+{
+ gfc_expr *result;
+ result = gfc_constant_result (BT_LOGICAL, kind, &src->where);
+ result->value.logical = (mpz_cmp_si (src->value.integer, 0) != 0);
+ return result;
+}
+