re PR fortran/36214 (Wrong simplification of BOZ constants)

2008-09-11  Daniel Kraft  <d@domob.eu>

	PR fortran/36214
	* simplify.c (simplify_cmplx): Added linebreak to long line.
	* target-memory.c (gfc_convert_boz): Fix indentation.
	(gfc_interpret_float): Set mpfr precision to right value before
	calling mpfr_init.

2008-09-11  Daniel Kraft  <d@domob.eu>

	PR fortran/36214
	* gfortran.dg/boz_9.f90: Corrected test.
	* gfortran.dg/boz_13.f90: New test.
	* gfortran.dg/boz_14.f90: New test.

From-SVN: r140264
This commit is contained in:
Daniel Kraft 2008-09-11 09:28:18 +02:00 committed by Daniel Kraft
parent 5993860d25
commit ace428e313
7 changed files with 55 additions and 9 deletions

View File

@ -1,3 +1,11 @@
2008-09-11 Daniel Kraft <d@domob.eu>
PR fortran/36214
* simplify.c (simplify_cmplx): Added linebreak to long line.
* target-memory.c (gfc_convert_boz): Fix indentation.
(gfc_interpret_float): Set mpfr precision to right value before
calling mpfr_init.
2008-09-10 H.J. Lu <hongjiu.lu@intel.com>
* expr.c (find_array_element): Reformat comment.

View File

@ -884,7 +884,8 @@ simplify_cmplx (const char *name, gfc_expr *x, gfc_expr *y, int kind)
{
case BT_INTEGER:
if (!y->is_boz)
mpfr_set_z (result->value.complex.i, y->value.integer, GFC_RND_MODE);
mpfr_set_z (result->value.complex.i, y->value.integer,
GFC_RND_MODE);
break;
case BT_REAL:

View File

@ -349,8 +349,9 @@ gfc_interpret_integer (int kind, unsigned char *buffer, size_t buffer_size,
int
gfc_interpret_float (int kind, unsigned char *buffer, size_t buffer_size,
mpfr_t real)
mpfr_t real)
{
gfc_set_model_kind (kind);
mpfr_init (real);
gfc_conv_tree_to_mpfr (real,
native_interpret_expr (gfc_get_real_type (kind),
@ -699,10 +700,8 @@ gfc_convert_boz (gfc_expr *expr, gfc_typespec *ts)
}
for (index = 0; gfc_integer_kinds[index].kind != 0; ++index)
{
if ((unsigned) gfc_integer_kinds[index].bit_size >= ts_bit_size)
break;
}
if ((unsigned) gfc_integer_kinds[index].bit_size >= ts_bit_size)
break;
expr->ts.kind = gfc_integer_kinds[index].kind;
buffer_size = MAX (buffer_size, size_integer (expr->ts.kind));

View File

@ -1,3 +1,10 @@
2008-09-11 Daniel Kraft <d@domob.eu>
PR fortran/36214
* gfortran.dg/boz_9.f90: Corrected test.
* gfortran.dg/boz_13.f90: New test.
* gfortran.dg/boz_14.f90: New test.
2008-09-10 Jakub Jelinek <jakub@redhat.com>
PR target/36904

View File

@ -0,0 +1,13 @@
! { dg-do run }
! PR fortran/36214
! For BOZ-initialization of floats, the precision used to be wrong sometimes.
implicit none
real, parameter :: r = 0.0
real(kind=8), parameter :: rd = real (z'00000000&
&402953FD', 8)
if (real (z'00000000&
&402953FD', 8) /= rd) call abort
end

View File

@ -0,0 +1,18 @@
! { dg-do run }
! PR fortran/36214
! For BOZ-initialization of floats, the precision used to be wrong sometimes.
implicit none
real(4) r
real(8) rd
complex(8) z
rd = &
real (b'00000000000000000000000000000000&
&01000000001010010101001111111101',8)
z = &
cmplx(b'00000000000000000000000000000000&
&01000000001010010101001111111101',0,8)
r = 0.
if (z /= rd) call abort
end

View File

@ -22,13 +22,13 @@ complex :: z2 = cmplx(5.0, o'01245')
if (r2c /= 13107.0) call abort()
if (rc /= 1.83668190E-41) call abort()
if (dc /= 0.30102999566398120) call abort()
if (dc /= 0.30102999566398120d0) call abort()
if (real(z1c) /= 2.94272678E-44 .or. aimag(z1c) /= -4.0) call abort()
if (real(z2c) /= 5.0 .or. aimag(z2c) /= 9.48679060E-43) call abort()
if (r2 /= 13107.0) call abort()
if (r /= 1.83668190E-41) call abort()
if (d /= 0.30102999566398120) call abort()
if (d /= 0.30102999566398120d0) call abort()
if (real(z1) /= 2.94272678E-44 .or. aimag(z1) /= -4.0) call abort()
if (real(z2) /= 5.0 .or. aimag(z2) /= 9.48679060E-43) call abort()
@ -40,7 +40,7 @@ z2 = cmplx(5.0, o'01245')
if (r2 /= 13107.0) call abort()
if (r /= 1.83668190E-41) call abort()
if (d /= 0.30102999566398120) call abort()
if (d /= 0.30102999566398120d0) call abort()
if (real(z1) /= 2.94272678E-44 .or. aimag(z1) /= -4.0) call abort()
if (real(z2) /= 5.0 .or. aimag(z2) /= 9.48679060E-43) call abort()