This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran,patch] PR fortran/28094, modulo for real(kind=10) variables






:ADDPATCH fortran:

Attached patch allows the front-end to create code for real kinds for
which there is no integer kind of the same size, e.g. real(kind=10),
or real(kind=16) on a machine without integer(kind=16).

It's kind of trivial, so I will commit it in a few days if noone
objects, but of course I'd welcome a review.

Bootstrapped and regtested on i686-linux. OK for mainline?



Index: trans-intrinsic.c
--- trans-intrinsic.c	(revision 114791)
+++ trans-intrinsic.c	(working copy)
@@ -860,7 +860,7 @@
  tree test;
  tree test2;
  mpfr_t huge;
-  int n;
+  int n, ikind;

  arg = gfc_conv_intrinsic_function_args (se, expr);
  arg2 = TREE_VALUE (TREE_CHAIN (arg));
@@ -886,7 +886,13 @@
      /* Test if the value is too large to handle sensibly.  */
      gfc_set_model_kind (expr->ts.kind);
      mpfr_init (huge);
-      n = gfc_validate_kind (BT_INTEGER, expr->ts.kind, false);
+      n = gfc_validate_kind (BT_INTEGER, expr->ts.kind, true);
+      ikind = expr->ts.kind;
+      if (n < 0)
+	{
+	  n = gfc_validate_kind (BT_INTEGER, gfc_max_integer_kind, false);
+	  ikind = gfc_max_integer_kind;
+	}
      mpfr_set_z (huge, gfc_integer_kinds[n].huge, GFC_RND_MODE);
      test = gfc_conv_mpfr_to_tree (huge, expr->ts.kind);
      test2 = build2 (LT_EXPR, boolean_type_node, tmp, test);
@@ -896,7 +902,7 @@
      test = build2 (GT_EXPR, boolean_type_node, tmp, test);
      test2 = build2 (TRUTH_AND_EXPR, boolean_type_node, test, test2);

- itype = gfc_get_int_type (expr->ts.kind);
+ itype = gfc_get_int_type (ikind);
if (modulo)
tmp = build_fix_expr (&se->pre, tmp, itype, FIX_FLOOR_EXPR);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]