re PR fortran/25458 ([4.1] Kind of constants in generic intrinsics)

PR fortran/25458
	* simplify.c (gfc_simplify_ibset, gfc_simplify_not): Add call to
	twos_complement.

	* gfortran.dg/chkbits.f90: New test.


Co-Authored-By: Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>

From-SVN: r108720
This commit is contained in:
Steven G. Kargl 2005-12-17 17:30:26 +00:00 committed by Steven G. Kargl
parent 573b07c751
commit ef98c52a44
4 changed files with 43 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2005-12-17 Steven G. Kargl <kargls@comcast.net>
Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/25458
* simplify.c (gfc_simplify_ibset, gfc_simplify_not): Add call to
twos_complement.
2005-12-17 Steven G. Kargl <kargls@comcast.net>
* decl.c (gfc_match_old_kind_spec,match_type_spec): Use gfc_std_notify

View file

@ -1348,6 +1348,9 @@ gfc_simplify_ibset (gfc_expr * x, gfc_expr * y)
result = gfc_copy_expr (x);
mpz_setbit (result->value.integer, pos);
twos_complement (result->value.integer, gfc_integer_kinds[k].bit_size);
return range_check (result, "IBSET");
}
@ -2514,6 +2517,8 @@ gfc_simplify_not (gfc_expr * e)
mpz_and (result->value.integer, result->value.integer,
gfc_integer_kinds[i].max_int);
twos_complement (result->value.integer, gfc_integer_kinds[i].bit_size);
return range_check (result, "NOT");
}

View file

@ -1,3 +1,8 @@
2005-12-17 Steven G. Kargl <kargls@comcast.net>
* PR fortran/25458
* gfortran.dg/chkbits.f90: New test.
2005-12-17 Steven G. Kargl <kargls@comcast.net>
*gfortran.dg/enum_5.f: Revert to previous version.

View file

@ -0,0 +1,26 @@
! { dg-do run }
! NOT() was not return the two's complement value as reported by
! PR fortran/25458. In checking other bit manipulation intrinsics,
! IBSET was found to be in error.
program chkbits
implicit none
integer(kind=1) i1
integer(kind=2) i2
integer(kind=4) i4
integer(kind=8) i8
i1 = ibset(2147483647,bit_size(i4)-1)
i2 = ibset(2147483647,bit_size(i4)-1)
i4 = ibset(2147483647,bit_size(i4)-1)
i8 = ibset(2147483647,bit_size(i4)-1)
if (i1 /= -1 .or. i2 /= -1 .or. i4 /= -1 .or. i8 /= -1) call abort
i1 = not(0)
i2 = not(0)
i4 = not(0)
i8 = not(0)
if (i1 /= -1 .or. i2 /= -1 .or. i4 /= -1 .or. i8 /= -1) call abort
end program chkbits