1! RUN: %B/test/Semantics/test_errors.sh %s %flang %t 2! Tests for C760: 3! The passed-object dummy argument shall be a scalar, nonpointer, nonallocatable 4! dummy data object with the same declared type as the type being defined; 5! all of its length type parameters shall be assumed; it shall be polymorphic 6! (7.3.2.3) if and only if the type being defined is extensible (7.5.7). 7! It shall not have the VALUE attribute. 8 9module m1 10 type :: t 11 procedure(real), pointer, nopass :: a 12 !ERROR: Procedure component 'b' must have NOPASS attribute or explicit interface 13 procedure(real), pointer :: b 14 end type 15end 16 17module m2 18 type :: t 19 !ERROR: Procedure component 'a' with no dummy arguments must have NOPASS attribute 20 procedure(s1), pointer :: a 21 !ERROR: Procedure component 'b' with no dummy arguments must have NOPASS attribute 22 procedure(s1), pointer, pass :: b 23 contains 24 !ERROR: Procedure binding 'p1' with no dummy arguments must have NOPASS attribute 25 procedure :: p1 => s1 26 !ERROR: Procedure binding 'p2' with no dummy arguments must have NOPASS attribute 27 procedure, pass :: p2 => s1 28 end type 29contains 30 subroutine s1() 31 end 32end 33 34module m3 35 type :: t 36 !ERROR: 'y' is not a dummy argument of procedure interface 's' 37 procedure(s), pointer, pass(y) :: a 38 contains 39 !ERROR: 'z' is not a dummy argument of procedure interface 's' 40 procedure, pass(z) :: p => s 41 end type 42contains 43 subroutine s(x) 44 class(t) :: x 45 end 46end 47 48module m4 49 type :: t 50 !ERROR: Passed-object dummy argument 'x' of procedure 'a' may not have the POINTER attribute 51 procedure(s1), pointer :: a 52 !ERROR: Passed-object dummy argument 'x' of procedure 'b' may not have the ALLOCATABLE attribute 53 procedure(s2), pointer, pass(x) :: b 54 !ERROR: Passed-object dummy argument 'f' of procedure 'c' must be a data object 55 procedure(s3), pointer, pass :: c 56 !ERROR: Passed-object dummy argument 'x' of procedure 'd' must be scalar 57 procedure(s4), pointer, pass :: d 58 end type 59contains 60 subroutine s1(x) 61 class(t), pointer :: x 62 end 63 subroutine s2(w, x) 64 real :: x 65 !ERROR: The type of 'x' has already been declared 66 class(t), allocatable :: x 67 end 68 subroutine s3(f) 69 interface 70 real function f() 71 end function 72 end interface 73 end 74 subroutine s4(x) 75 class(t) :: x(10) 76 end 77end 78 79module m5 80 type :: t1 81 sequence 82 !ERROR: Passed-object dummy argument 'x' of procedure 'a' must be of type 't1' but is 'REAL(4)' 83 procedure(s), pointer :: a 84 end type 85 type :: t2 86 contains 87 !ERROR: Passed-object dummy argument 'y' of procedure 's' must be of type 't2' but is 'TYPE(t1)' 88 procedure, pass(y) :: s 89 end type 90contains 91 subroutine s(x, y) 92 real :: x 93 type(t1) :: y 94 end 95end 96 97module m6 98 type :: t(k, l) 99 integer, kind :: k 100 integer, len :: l 101 !ERROR: Passed-object dummy argument 'x' of procedure 'a' has non-assumed length parameter 'l' 102 procedure(s1), pointer :: a 103 end type 104contains 105 subroutine s1(x) 106 class(t(1, 2)) :: x 107 end 108end 109 110module m7 111 type :: t 112 sequence ! t is not extensible 113 !ERROR: Passed-object dummy argument 'x' of procedure 'a' may not be polymorphic because 't' is not extensible 114 procedure(s), pointer :: a 115 end type 116contains 117 subroutine s(x) 118 !ERROR: Non-extensible derived type 't' may not be used with CLASS keyword 119 class(t) :: x 120 end 121end 122 123module m8 124 type :: t 125 contains 126 !ERROR: Passed-object dummy argument 'x' of procedure 's' must be polymorphic because 't' is extensible 127 procedure :: s 128 end type 129contains 130 subroutine s(x) 131 type(t) :: x ! x is not polymorphic 132 end 133end 134