1! RUN: %python %S/test_errors.py %s %flang_fc1 2! Confirm enforcement of constraints and restrictions in 7.7 3! C7107, C7108, C7109 4 5subroutine bozchecks 6 ! Type declaration statements 7 integer :: f, realpart = B"0101", img = B"1111", resint 8 logical :: resbit 9 complex :: rescmplx 10 real :: dbl, e 11 interface 12 subroutine explicit(n, x, c) 13 integer :: n 14 real :: x 15 character :: c 16 end subroutine 17 end interface 18 ! C7107 19 !ERROR: Invalid digit ('a') in BOZ literal 'b"110a"' 20 integer, parameter :: a = B"110A" 21 !ERROR: Invalid digit ('2') in BOZ literal 'b"1232"' 22 integer, parameter :: b = B"1232" 23 !ERROR: BOZ literal 'b"010101010101010101010101011111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000"' too large 24 integer, parameter :: b1 = B"010101010101010101010101011111111111111111111& 25 &111111111111111111111111111111111111111111111& 26 &111111111111111111000000000000000000000000000& 27 &000000000" 28 ! C7108 29 !ERROR: Invalid digit ('8') in BOZ literal 'o"8"' 30 integer :: c = O"8" 31 !ERROR: Invalid digit ('a') in BOZ literal 'o"a"' 32 integer :: d = O"A" 33 34 ! C7109 35 ! A) can appear only in data statement 36 ! B) Argument to intrinsics listed from 16.9 below 37 ! BGE, BGT, BLE, BLT, CMPLX, DBLE, DSHIFTL, 38 ! DSHIFTR, IAND, IEOR, INT, IOR, MERGE_BITS, REAL 39 ! and legacy aliases AND, OR, XOR 40 41 ! part A 42 data f / Z"AA" / ! OK 43 !ERROR: DATA statement value could not be converted to the type 'COMPLEX(4)' of the object 'rescmplx' 44 data rescmplx / B"010101" / 45 ! part B 46 resbit = BGE(B"0101", B"1111") 47 resbit = BGT(Z"0101", B"1111") 48 resbit = BLE(B"0101", B"1111") 49 resbit = BLT(B"0101", B"1111") 50 51 res = CMPLX (realpart, img, 4) 52 res = CMPLX (B"0101", B"1111", 4) 53 54 dbl = DBLE(B"1111") 55 dbl = DBLE(realpart) 56 57 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments 58 dbl = DSHIFTL(B"0101",B"0101",2) 59 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments 60 dbl = DSHIFTR(B"1010",B"1010",2) 61 dbl = DSHIFTL(B"0101",5,2) ! OK 62 dbl = DSHIFTR(B"1010",5,2) ! OK 63 64 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments 65 resint = IAND(B"0001", B"0011") 66 resint = IAND(B"0001", 3) 67 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments 68 resint = AND(B"0001", B"0011") 69 resint = AND(B"0001", 3) 70 71 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments 72 resint = IEOR(B"0001", B"0011") 73 resint = IEOR(B"0001", 3) 74 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments 75 resint = XOR(B"0001", B"0011") 76 resint = XOR(B"0001", 3) 77 78 resint = INT(B"1010") 79 80 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments 81 res = IOR(B"0101", B"0011") 82 res = IOR(B"0101", 3) 83 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments 84 res = OR(B"0101", B"0011") 85 res = OR(B"0101", 3) 86 87 res = MERGE_BITS(13,3,11) 88 res = MERGE_BITS(B"1101",3,11) 89 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments 90 res = MERGE_BITS(B"1101",B"0011",11) 91 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments 92 res = MERGE_BITS(B"1101",B"0011",B"1011") 93 res = MERGE_BITS(B"1101",3,B"1011") 94 95 !ERROR: Typeless (BOZ) not allowed for 'x=' argument 96 res = KIND(z'feedface') 97 98 res = REAL(B"1101") 99 100 !Ok 101 call explicit(z'deadbeef', o'666', 'a') 102 103 !ERROR: Actual argument 'z'55'' associated with dummy argument 'c=' is not a variable or typed expression 104 call explicit(z'deadbeef', o'666', b'01010101') 105 106 !ERROR: BOZ argument requires an explicit interface 107 call implictSub(Z'12345') 108 109 !ERROR: Output item must not be a BOZ literal constant 110 print "(Z18)", Z"76543210" 111end subroutine 112