| 1 |
! { dg-do run } |
| 2 |
! { dg-options "-fcheck=bits -fdump-tree-original" } |
| 3 |
! { dg-shouldfail "Fortran runtime error: FROMPOS(64)+LEN(1)>BIT_SIZE(64) in intrinsic MVBITS" } |
| 4 |
! { dg-output "At line 33 .*" } |
| 5 |
! |
| 6 |
! Verify that the runtime checks for the MVBITS intrinsic functions |
| 7 |
! do not generate false-positives |
| 8 |
program check |
| 9 |
implicit none |
| 10 |
integer, parameter :: bs4 = bit_size (1_4) |
| 11 |
integer, parameter :: bs8 = bit_size (1_8) |
| 12 |
integer(4), dimension(0:bs4) :: from4, frompos4, len4, to4, topos4 |
| 13 |
integer(8), dimension(0:bs8) :: from8, frompos8, len8, to8, topos8 |
| 14 |
integer :: i |
| 15 |
from4 = -1 |
| 16 |
to4 = -1 |
| 17 |
len4 = [ (i, i=0,bs4) ] |
| 18 |
frompos4 = bs4 - len4 |
| 19 |
topos4 = frompos4 |
| 20 |
call mvbits (from4, frompos4, len4, to4, topos4) |
| 21 |
if (any (to4 /= -1)) stop 1 |
| 22 |
from8 = -1 |
| 23 |
to8 = -1 |
| 24 |
len8 = [ (i, i=0,bs8) ] |
| 25 |
frompos8 = bs8 - len8 |
| 26 |
topos8 = frompos8 |
| 27 |
call mvbits (from8, frompos8, len8, to8, topos8) |
| 28 |
if (any (to8 /= -1)) stop 2 |
| 29 |
from8 = -1 |
| 30 |
to8 = -1 |
| 31 |
len8(0) = 1 |
| 32 |
! The following line should fail with a runtime error: |
| 33 |
call mvbits (from8, frompos8, len8, to8, topos8) |
| 34 |
! Should never get here with -fcheck=bits |
| 35 |
stop 3 |
| 36 |
end |
| 37 |
|
| 38 |
! { dg-final { scan-tree-dump-times "_gfortran_runtime_error_at" 15 "original" } } |