135 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Ensure that INDEX is a usable specific intrinsic procedure.3 4program test5 interface6 pure integer function index1(string, substring)7 character(*), intent(in) :: string, substring ! ok8 end9 pure integer function index2(x1, x2)10 character(*), intent(in) :: x1, x2 ! ok11 end12 pure integer function index3(string, substring)13 character, intent(in) :: string, substring ! not assumed length14 end15 pure integer function index4(string, substring, back)16 character(*), intent(in) :: string, substring17 logical, optional, intent(in) :: back ! not ok18 end19 subroutine s0(ix)20 procedure(index) :: ix21 end22 subroutine s1(ix)23 import index124 procedure(index1) :: ix25 end26 subroutine s2(ix)27 import index228 procedure(index2) :: ix29 end30 subroutine s3(ix)31 import index332 procedure(index3) :: ix33 end34 subroutine s4(ix)35 import index436 procedure(index4) :: ix37 end38 end interface39 40 procedure(index), pointer :: p041 procedure(index1), pointer :: p142 procedure(index2), pointer :: p243 procedure(index3), pointer :: p344 procedure(index4), pointer :: p445 46 p0 => index ! ok47 p0 => index1 ! ok48 p0 => index2 ! ok49 !ERROR: Procedure pointer 'p0' associated with incompatible procedure designator 'index3': incompatible dummy argument #1: assumed-length character vs explicit-length character50 p0 => index351 !ERROR: Procedure pointer 'p0' associated with incompatible procedure designator 'index4': distinct numbers of dummy arguments52 p0 => index453 p1 => index ! ok54 p1 => index1 ! ok55 p1 => index2 ! ok56 !ERROR: Procedure pointer 'p1' associated with incompatible procedure designator 'index3': incompatible dummy argument #1: assumed-length character vs explicit-length character57 p1 => index358 !ERROR: Procedure pointer 'p1' associated with incompatible procedure designator 'index4': distinct numbers of dummy arguments59 p1 => index460 p2 => index ! ok61 p2 => index1 ! ok62 p2 => index2 ! ok63 !ERROR: Procedure pointer 'p2' associated with incompatible procedure designator 'index3': incompatible dummy argument #1: assumed-length character vs explicit-length character64 p2 => index365 !ERROR: Procedure pointer 'p2' associated with incompatible procedure designator 'index4': distinct numbers of dummy arguments66 p2 => index467 !ERROR: Procedure pointer 'p3' associated with incompatible procedure designator 'index': incompatible dummy argument #1: assumed-length character vs explicit-length character68 p3 => index69 !ERROR: Procedure pointer 'p3' associated with incompatible procedure designator 'index1': incompatible dummy argument #1: assumed-length character vs explicit-length character70 p3 => index171 !ERROR: Procedure pointer 'p3' associated with incompatible procedure designator 'index2': incompatible dummy argument #1: assumed-length character vs explicit-length character72 p3 => index273 p3 => index3 ! ok74 !ERROR: Procedure pointer 'p3' associated with incompatible procedure designator 'index4': distinct numbers of dummy arguments75 p3 => index476 !ERROR: Procedure pointer 'p4' associated with incompatible procedure designator 'index': distinct numbers of dummy arguments77 p4 => index78 !ERROR: Procedure pointer 'p4' associated with incompatible procedure designator 'index1': distinct numbers of dummy arguments79 p4 => index180 !ERROR: Procedure pointer 'p4' associated with incompatible procedure designator 'index2': distinct numbers of dummy arguments81 p4 => index282 !ERROR: Procedure pointer 'p4' associated with incompatible procedure designator 'index3': distinct numbers of dummy arguments83 p4 => index384 p4 => index4 ! ok85 86 call s0(index) ! ok87 call s0(index1) ! ok88 call s0(index2)89 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': incompatible dummy argument #1: assumed-length character vs explicit-length character90 call s0(index3)91 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': distinct numbers of dummy arguments92 call s0(index4)93 call s1(index) ! ok94 call s1(index1) ! ok95 call s1(index2) ! ok96 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': incompatible dummy argument #1: assumed-length character vs explicit-length character97 call s1(index3)98 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': distinct numbers of dummy arguments99 call s1(index4)100 call s2(index) ! ok101 call s2(index1) ! ok102 call s2(index2) ! ok103 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': incompatible dummy argument #1: assumed-length character vs explicit-length character104 call s2(index3)105 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': distinct numbers of dummy arguments106 call s2(index4)107 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': incompatible dummy argument #1: assumed-length character vs explicit-length character108 call s3(index)109 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': incompatible dummy argument #1: assumed-length character vs explicit-length character110 call s3(index1)111 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': incompatible dummy argument #1: assumed-length character vs explicit-length character112 call s3(index2)113 call s3(index3) ! ok114 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': distinct numbers of dummy arguments115 call s3(index4)116 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': distinct numbers of dummy arguments117 call s4(index)118 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': distinct numbers of dummy arguments119 call s4(index1)120 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': distinct numbers of dummy arguments121 call s4(index2)122 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'ix=': distinct numbers of dummy arguments123 call s4(index3)124 call s4(index4) ! ok125end126 127subroutine ichar_tests()128 integer, parameter :: a1 = ichar('B')129 !Without -Wportability, the warning isn't emitted and the parameter is constant.130 integer, parameter :: a2 = ichar('B ')131 !ERROR: Character in intrinsic function ichar must have length one132 !ERROR: Value of named constant 'a3' (ichar("")) cannot be computed as a constant value133 integer, parameter :: a3 = ichar('')134end subroutine135