1! RUN: %S/test_errors.sh %s %t %flang_fc1 2! REQUIRES: shell 3! Tests based on examples in C.10.6 4 5! C.10.6(10) 6module m1 7 interface GOOD1 8 function F1A(X) 9 real :: F1A, X 10 end function 11 function F1B(X) 12 integer :: F1B, X 13 end function 14 end interface 15end 16 17! C.10.6(13) 18module m2 19 interface GOOD2 20 function F2A(X) 21 real :: F2A, X 22 end function 23 function F2B(X, Y) 24 complex :: F2B 25 real :: X, Y 26 end function 27 end interface 28end 29 30! C.10.6(15) 31module m3 32 interface GOOD3 33 subroutine S3A(W, X, Y, Z) 34 real :: W, Y 35 integer :: X, Z 36 end subroutine 37 subroutine S3B(X, W, Z, Y) 38 real :: W, Z 39 integer :: X, Y 40 end subroutine 41 end interface 42end 43module m3b 44 interface GOOD3 45 subroutine S3B(X, W, Z, Y) 46 real :: W, Z 47 integer :: X, Y 48 end subroutine 49 subroutine S3A(W, X, Y, Z) 50 real :: W, Y 51 integer :: X, Z 52 end subroutine 53 end interface 54end 55 56! C.10.6(17) 57! BAD4(1.0,2,Y=3.0,Z=4) could apply to either procedure 58module m4 59 !ERROR: Generic 'bad4' may not have specific procedures 's4a' and 's4b' as their interfaces are not distinguishable 60 interface BAD4 61 subroutine S4A(W, X, Y, Z) 62 real :: W, Y 63 integer :: X, Z 64 end subroutine 65 subroutine S4B(X, W, Z, Y) 66 real :: X, Y 67 integer :: W, Z 68 end subroutine 69 end interface 70end 71module m4b 72 !ERROR: Generic 'bad4' may not have specific procedures 's4b' and 's4a' as their interfaces are not distinguishable 73 interface BAD4 74 subroutine S4B(X, W, Z, Y) 75 real :: X, Y 76 integer :: W, Z 77 end subroutine 78 subroutine S4A(W, X, Y, Z) 79 real :: W, Y 80 integer :: X, Z 81 end subroutine 82 end interface 83end 84 85! C.10.6(19) 86module m5 87 interface GOOD5 88 subroutine S5A(X) 89 real :: X 90 end subroutine 91 subroutine S5B(Y, X) 92 real :: Y, X 93 end subroutine 94 end interface 95end 96 97module FRUITS 98 type :: FRUIT 99 end type 100 type, extends(FRUIT) :: APPLE 101 end type 102 type, extends(FRUIT) :: PEAR 103 end type 104 type, extends(PEAR) :: BOSC 105 end type 106end 107 108! C.10.6(21) 109! type(PEAR) :: A_PEAR 110! type(BOSC) :: A_BOSC 111! BAD6(A_PEAR,A_BOSC) ! could be s6a or s6b 112module m6 113 !ERROR: Generic 'bad6' may not have specific procedures 's6a' and 's6b' as their interfaces are not distinguishable 114 interface BAD6 115 subroutine S6A(X, Y) 116 use FRUITS 117 class(PEAR) :: X, Y 118 end subroutine 119 subroutine S6B(X, Y) 120 use FRUITS 121 class(FRUIT) :: X 122 class(BOSC) :: Y 123 end subroutine 124 end interface 125end 126module m6b 127 !ERROR: Generic 'bad6' may not have specific procedures 's6b' and 's6a' as their interfaces are not distinguishable 128 interface BAD6 129 subroutine S6B(X, Y) 130 use FRUITS 131 class(FRUIT) :: X 132 class(BOSC) :: Y 133 end subroutine 134 subroutine S6A(X, Y) 135 use FRUITS 136 class(PEAR) :: X, Y 137 end subroutine 138 end interface 139end 140 141! C.10.6(22) 142module m7 143 interface GOOD7 144 subroutine S7A(X, Y, Z) 145 use FRUITS 146 class(PEAR) :: X, Y, Z 147 end subroutine 148 subroutine S7B(X, Z, W) 149 use FRUITS 150 class(FRUIT) :: X 151 class(BOSC) :: Z 152 class(APPLE), optional :: W 153 end subroutine 154 end interface 155end 156module m7b 157 interface GOOD7 158 subroutine S7B(X, Z, W) 159 use FRUITS 160 class(FRUIT) :: X 161 class(BOSC) :: Z 162 class(APPLE), optional :: W 163 end subroutine 164 subroutine S7A(X, Y, Z) 165 use FRUITS 166 class(PEAR) :: X, Y, Z 167 end subroutine 168 end interface 169end 170 171! C.10.6(25) 172! Invalid generic (according to the rules), despite the fact that it is unambiguous 173module m8 174 !ERROR: Generic 'bad8' may not have specific procedures 's8a' and 's8b' as their interfaces are not distinguishable 175 interface BAD8 176 subroutine S8A(X, Y, Z) 177 real, optional :: X 178 integer :: Y 179 real :: Z 180 end subroutine 181 subroutine S8B(X, Z, Y) 182 integer, optional :: X 183 integer :: Z 184 real :: Y 185 end subroutine 186 end interface 187end 188