diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b0b39a317421159a346e0bdd8101d679a8c69cc1..4c5dc8f206cc7d2387c7b85598ff92fb97b0064b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,7 +1,12 @@ +2006-02-07 Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de> + + PR fortran/25577 + * gfortran.dg/mvbits_1.f90: New. + 2006-02-07 Dirk Mueller <dmueller@suse.com> - g++.dg/warn/Wdiv-by-zero.C: New test. - g++.dg/warn/Wno-div-by-zero.C: New. + * g++.dg/warn/Wdiv-by-zero.C: New test. + * g++.dg/warn/Wno-div-by-zero.C: New. 2006-02-07 Jeff Law <law@redhat.com> diff --git a/gcc/testsuite/gfortran.dg/mvbits_1.f90 b/gcc/testsuite/gfortran.dg/mvbits_1.f90 new file mode 100644 index 0000000000000000000000000000000000000000..90e92bb0e2654addaa5451eb87b93526394e4eb4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/mvbits_1.f90 @@ -0,0 +1,39 @@ +! PR 25577 +! MVBITS didn't work correctly for integer types wider than a C int +! The testcase is based on the one Dale Ranta posted in the bug report +implicit none +integer(1) i1,j1 +integer(2) i2,j2 +integer(4) i4,j4 +integer(8) i8,j8 +integer ibits,n + +ibits=bit_size(1_1) +do n=1,ibits + i1=-1 + call mvbits(1_1, 0,n,i1,0) + j1=-1-2_1**n+2 + if(i1.ne.j1)call abort +enddo +ibits=bit_size(1_2) +do n=1,ibits + i2=-1 + call mvbits(1_2, 0,n,i2,0) + j2=-1-2_2**n+2 + if(i2.ne.j2)call abort +enddo +ibits=bit_size(1_4) +do n=1,ibits + i4=-1 + call mvbits(1_4, 0,n,i4,0) + j4=-1-2_4**n+2 + if(i4.ne.j4)call abort +enddo +ibits=bit_size(1_8) +do n=1,ibits + i8=-1 + call mvbits(1_8, 0,n,i8,0) + j8=-1-2_8**n+2 + if(i8.ne.j8)call abort +enddo +end diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index a48b5d800686689d6130acde77d9f533a84009df..8517787a1a770de5e4fd9ce085a4444a4719abc0 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2006-02-07 Dale Ranta <dir@lanl.gov> + + PR fortran/25577 + * intrinsics/mvbits.c: Shift '(TYPE)1' type when building 'lenmask'. + 2006-02-07 Rainer Emrich <r.emrich@de.tecosim.com> * intrinsics/c99_functions.c: Work around incompatible diff --git a/libgfortran/intrinsics/mvbits.c b/libgfortran/intrinsics/mvbits.c index 6bfb5cad85bf97e9d061d01f7195b9f5444e80b1..a452fc98b3f73fdec1719d4a96d3fe5f89ccf800 100644 --- a/libgfortran/intrinsics/mvbits.c +++ b/libgfortran/intrinsics/mvbits.c @@ -1,5 +1,5 @@ /* Implementation of the MVBITS intrinsic - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. Contributed by Tobias Schlüter This file is part of the GNU Fortran 95 runtime library (libgfortran). @@ -48,7 +48,7 @@ SUB_NAME (const TYPE *from, const GFC_INTEGER_4 *frompos, { TYPE oldbits, newbits, lenmask; - lenmask = (*len == sizeof (TYPE)*8) ? ~(TYPE)0 : (1 << *len) - 1; + lenmask = (*len == sizeof (TYPE)*8) ? ~(TYPE)0 : ((TYPE)1 << *len) - 1; newbits = (((UTYPE)(*from) >> *frompos) & lenmask) << *topos; oldbits = *to & (~(lenmask << *topos));