129 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Confirm enforcement of constraints and restrictions in 7.73! C7107, C7108, C71094 5subroutine bozchecks6 ! Type declaration statements7 integer :: f, realpart = B"0101", img = B"1111", resint8 logical :: resbit9 complex :: rescmplx10 character :: reschar11 real :: dbl, e12 type :: dt13 integer :: n14 end type15 type(dt) :: resdt16 interface17 subroutine explicit(n, x, c)18 integer :: n19 real :: x20 character :: c21 end subroutine22 end interface23 ! C710724 !ERROR: Invalid digit ('a') in BOZ literal 'b"110a"'25 integer, parameter :: a = B"110A"26 !ERROR: Invalid digit ('2') in BOZ literal 'b"1232"'27 integer, parameter :: b = B"1232"28 !ERROR: BOZ literal 'b"010101010101010101010101011111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000"' too large29 integer, parameter :: b1 = B"010101010101010101010101011111111111111111111&30 &111111111111111111111111111111111111111111111&31 &111111111111111111000000000000000000000000000&32 &000000000"33 ! C710834 !ERROR: Invalid digit ('8') in BOZ literal 'o"8"'35 integer :: c = O"8"36 !ERROR: Invalid digit ('a') in BOZ literal 'o"a"'37 integer :: d = O"A"38 39 ! C710940 ! A) can appear only in data statement41 ! B) Argument to intrinsics listed from 16.9 below42 ! BGE, BGT, BLE, BLT, CMPLX, DBLE, DSHIFTL,43 ! DSHIFTR, IAND, IEOR, INT, IOR, MERGE_BITS, REAL44 ! and legacy aliases AND, OR, XOR45 46 ! part A47 data f / Z"AA" / ! OK48 !ERROR: DATA statement value could not be converted to the type 'COMPLEX(4)' of the object 'rescmplx'49 data rescmplx / B"010101" /50 ! part B51 resbit = BGE(B"0101", B"1111")52 resbit = BGT(Z"0101", B"1111")53 resbit = BLE(B"0101", B"1111")54 resbit = BLT(B"0101", B"1111")55 56 res = CMPLX (realpart, img, 4)57 res = CMPLX (B"0101", B"1111", 4)58 59 !WARNING: underflow on REAL(8) to REAL(4) conversion [-Wfolding-exception]60 dbl = DBLE(B"1111")61 dbl = DBLE(realpart)62 63 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments64 dbl = DSHIFTL(B"0101",B"0101",2)65 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments66 dbl = DSHIFTR(B"1010",B"1010",2)67 dbl = DSHIFTL(B"0101",5,2) ! OK68 dbl = DSHIFTR(B"1010",5,2) ! OK69 70 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments71 resint = IAND(B"0001", B"0011")72 resint = IAND(B"0001", 3)73 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments74 resint = AND(B"0001", B"0011")75 resint = AND(B"0001", 3)76 77 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments78 resint = IEOR(B"0001", B"0011")79 resint = IEOR(B"0001", 3)80 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments81 resint = XOR(B"0001", B"0011")82 resint = XOR(B"0001", 3)83 84 resint = INT(B"1010")85 86 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments87 res = IOR(B"0101", B"0011")88 res = IOR(B"0101", 3)89 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments90 res = OR(B"0101", B"0011")91 res = OR(B"0101", 3)92 93 res = MERGE_BITS(13,3,11)94 res = MERGE_BITS(B"1101",3,11)95 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments96 res = MERGE_BITS(B"1101",B"0011",11)97 !ERROR: Typeless (BOZ) not allowed for both 'i=' & 'j=' arguments98 res = MERGE_BITS(B"1101",B"0011",B"1011")99 res = MERGE_BITS(B"1101",3,B"1011")100 101 !ERROR: Typeless (BOZ) not allowed for 'x=' argument102 res = KIND(z'feedface')103 104 res = REAL(B"1101")105 106 resint = z'ff' ! ok107 res = z'3f800000' ! ok108 !ERROR: Right-hand side of this assignment may not be BOZ109 rescmplx = z'123'110 !ERROR: Right-hand side of this assignment may not be BOZ111 resbit = z'123'112 !ERROR: Right-hand side of this assignment may not be BOZ113 reschar = z'123'114 !ERROR: Right-hand side of this assignment may not be BOZ115 resdt = z'123'116 117 !Ok118 call explicit(z'deadbeef', o'666', 'a')119 120 !ERROR: Actual argument 'z'55'' associated with dummy argument 'c=' is not a variable or typed expression121 call explicit(z'deadbeef', o'666', b'01010101')122 123 !ERROR: BOZ argument z'12345' requires an explicit interface124 call implictSub(Z'12345')125 126 !ERROR: Output item must not be a BOZ literal constant127 print "(Z18)", Z"76543210"128end subroutine129