summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-17 17:30:26 +0000
committerkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-17 17:30:26 +0000
commitfb6e45cd3925cef0b7ac1fec78669cda196eeda9 (patch)
tree34700f2c118f9dc255183f0bbb29babc379f826b
parent0ff8da43cab240367a911698c46e81c8e6b202f3 (diff)
downloadgcc-fb6e45cd3925cef0b7ac1fec78669cda196eeda9.tar.gz
PR fortran/25458
* simplify.c (gfc_simplify_ibset, gfc_simplify_not): Add call to twos_complement. * gfortran.dg/chkbits.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108720 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/simplify.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/chkbits.f9026
4 files changed, 43 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 882332dffa1..98e624a830e 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,4 +1,11 @@
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
to report nonstandard intrinsic type declarations.
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index e6fbefcfe5b..5b47e930db6 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -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");
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a45284b7ecb..b7e00b9046a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
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.
2005-12-17 Steven G. Kargl <kargls@comcast.net>
diff --git a/gcc/testsuite/gfortran.dg/chkbits.f90 b/gcc/testsuite/gfortran.dg/chkbits.f90
new file mode 100644
index 00000000000..19ab5c722c6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/chkbits.f90
@@ -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