aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2022-09-21 11:06:19 +0200
committerFrancois-Xavier Coudert <fxcoudert@gmail.com>2022-09-21 11:15:21 +0200
commit519196a27cf534e94f158733b25a4f9d10737031 (patch)
tree5975060cec8fbe5e33d55feeb6d0f24175d480da /gcc
parentdd9e5f4db2debf1429feab7f785962ccef6e0dbd (diff)
downloadgcc-519196a27cf534e94f158733b25a4f9d10737031.zip
gcc-519196a27cf534e94f158733b25a4f9d10737031.tar.gz
gcc-519196a27cf534e94f158733b25a4f9d10737031.tar.bz2
Fortran: handle RADIX kind in IEEE_SET_ROUNDING_MODE
Make sure that calling IEEE_SET_ROUNDING_MODE with RADIX=10 does not affect the binary rounding mode. 2022-09-21 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> libgfortran/ * ieee/ieee_arithmetic.F90 (IEEE_SET_ROUNDING_MODE): Handle RADIX argument better. gcc/testsuite/ * gfortran.dg/ieee/rounding_3.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gfortran.dg/ieee/rounding_3.f9027
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/ieee/rounding_3.f90 b/gcc/testsuite/gfortran.dg/ieee/rounding_3.f90
new file mode 100644
index 0000000..ff4e834
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/ieee/rounding_3.f90
@@ -0,0 +1,27 @@
+! { dg-do run }
+
+ ! Test IEEE_GET_ROUNDING_MODE and IEEE_SET_ROUNDING_MODE
+ ! with a RADIX argument
+ use, intrinsic :: ieee_arithmetic
+ implicit none
+
+ real :: sx1
+ type(ieee_round_type) :: r
+
+ if (ieee_support_rounding(ieee_up, sx1) .and. &
+ ieee_support_rounding(ieee_down, sx1)) then
+
+ call ieee_set_rounding_mode(ieee_up)
+ call ieee_get_rounding_mode(r)
+ if (r /= ieee_up) stop 1
+
+ call ieee_set_rounding_mode(ieee_down, radix=2)
+ call ieee_get_rounding_mode(r, radix=2)
+ if (r /= ieee_down) stop 2
+
+ call ieee_set_rounding_mode(ieee_up, radix=10)
+ call ieee_get_rounding_mode(r, radix=2)
+ if (r /= ieee_down) stop 3
+ end if
+
+end