]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/fortran/trans-intrinsic.c
PR fortran/96711 - ICE with NINT() for integer(16) result
[gcc.git] / gcc / fortran / trans-intrinsic.c
index 2483f016d8e9ecf92c5092d9c6a5542d690ecddd..32fe9886c5785fac6295bec0f80427c719383dad 100644 (file)
@@ -395,11 +395,24 @@ build_round_expr (tree arg, tree restype)
     fn = builtin_decl_for_precision (BUILT_IN_LROUND, argprec);
   else if (resprec <= LONG_LONG_TYPE_SIZE)
     fn = builtin_decl_for_precision (BUILT_IN_LLROUND, argprec);
+  else if (resprec >= argprec && resprec == 128)
+    {
+      /* Search for a real kind suitable as temporary for conversion.  */
+      int kind = -1;
+      for (int i = 0; kind < 0 && gfc_real_kinds[i].kind != 0; i++)
+       if (gfc_real_kinds[i].mode_precision >= resprec)
+         kind = gfc_real_kinds[i].kind;
+      if (kind < 0)
+       gfc_internal_error ("Could not find real kind with at least %d bits",
+                           resprec);
+      arg = fold_convert (gfc_float128_type_node, arg);
+      fn = gfc_builtin_decl_for_float_kind (BUILT_IN_ROUND, kind);
+    }
   else
     gcc_unreachable ();
 
-  return fold_convert (restype, build_call_expr_loc (input_location,
-                                                fn, 1, arg));
+  return convert (restype, build_call_expr_loc (input_location,
+                                               fn, 1, arg));
 }
 
 
This page took 0.03008 seconds and 5 git commands to generate.