diff options
-rw-r--r-- | gcc/fortran/check.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr96859.f90 | 25 |
2 files changed, 29 insertions, 4 deletions
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 65b46cd..1e64fab 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -340,9 +340,9 @@ gfc_boz2real (gfc_expr *x, int kind) /* Clear first two bits. */ else { - if (buf[0] == '4' || buf[0] == '6') + if (buf[0] == '2' || buf[0] == '4' || buf[0] == '6') buf[0] = '0'; - else if (buf[0] == '5' || buf[0] == '7') + else if (buf[0] == '3' || buf[0] == '5' || buf[0] == '7') buf[0] = '1'; } } @@ -429,9 +429,9 @@ gfc_boz2int (gfc_expr *x, int kind) /* Clear first two bits. */ else { - if (buf[0] == '4' || buf[0] == '6') + if (buf[0] == '2' || buf[0] == '4' || buf[0] == '6') buf[0] = '0'; - else if (buf[0] == '5' || buf[0] == '7') + else if (buf[0] == '3' || buf[0] == '5' || buf[0] == '7') buf[0] = '1'; } } diff --git a/gcc/testsuite/gfortran.dg/pr96859.f90 b/gcc/testsuite/gfortran.dg/pr96859.f90 new file mode 100644 index 0000000..ca41cef --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr96859.f90 @@ -0,0 +1,25 @@ +! PR fortran/96859 +! { dg-do run } + +program pr96859 + if (merge_bits(32767_2, o'1234567', 32767_2).ne.32767_2) stop 1 + if (merge_bits(o'1234567', 32767_2, o'1234567').ne.32767_2) stop 2 + if (merge_bits(32767_2, o'1234567', b'010101').ne.14711_2) stop 3 + if (merge_bits(32767_2, o'1234567', z'12345678').ne.32639_2) stop 4 + if (int (o'1034567', 2).ne.14711_2) stop 5 + if (int (o'1234567', 2).ne.14711_2) stop 6 + if (int (o'1434567', 2).ne.14711_2) stop 7 + if (int (o'1634567', 2).ne.14711_2) stop 8 + if (int (o'1134567', 2).ne.-18057_2) stop 9 + if (int (o'1334567', 2).ne.-18057_2) stop 10 + if (int (o'1534567', 2).ne.-18057_2) stop 11 + if (int (o'1734567', 2).ne.-18057_2) stop 12 + if (int (o'70123456776543211234567', 8).ne.1505855851274254711_8) stop 13 + if (int (o'72123456776543211234567', 8).ne.1505855851274254711_8) stop 14 + if (int (o'74123456776543211234567', 8).ne.1505855851274254711_8) stop 15 + if (int (o'76123456776543211234567', 8).ne.1505855851274254711_8) stop 16 + if (int (o'71123456776543211234567', 8).ne.-7717516185580521097_8) stop 17 + if (int (o'73123456776543211234567', 8).ne.-7717516185580521097_8) stop 18 + if (int (o'75123456776543211234567', 8).ne.-7717516185580521097_8) stop 19 + if (int (o'77123456776543211234567', 8).ne.-7717516185580521097_8) stop 20 +end |