1! RUN: %S/test_errors.sh %s %t %f18 2! Extended derived types 3 4module m1 5 type :: t1 6 integer :: x 7 !ERROR: Component 'x' is already declared in this derived type 8 real :: x 9 end type 10end 11 12module m2 13 type :: t1 14 integer :: i 15 end type 16 type, extends(t1) :: t2 17 !ERROR: Component 'i' is already declared in a parent of this derived type 18 integer :: i 19 end type 20end 21 22module m3 23 type :: t1 24 end type 25 type, extends(t1) :: t2 26 integer :: i 27 !ERROR: 't1' is a parent type of this type and so cannot be a component 28 real :: t1 29 end type 30 type :: t3 31 end type 32 type, extends(t3) :: t4 33 end type 34 type, extends(t4) :: t5 35 !ERROR: 't3' is a parent type of this type and so cannot be a component 36 real :: t3 37 end type 38end 39 40module m4 41 type :: t1 42 integer :: t1 43 end type 44 !ERROR: Type cannot be extended as it has a component named 't1' 45 type, extends(t1) :: t2 46 end type 47end 48 49module m5 50 type :: t1 51 integer :: t2 52 end type 53 type, extends(t1) :: t2 54 end type 55 !ERROR: Type cannot be extended as it has a component named 't2' 56 type, extends(t2) :: t3 57 end type 58end 59 60module m6 61 ! t1 can be extended if it is known as anything but t3 62 type :: t1 63 integer :: t3 64 end type 65 type, extends(t1) :: t2 66 end type 67end 68subroutine s6 69 use :: m6, only: t3 => t1 70 !ERROR: Type cannot be extended as it has a component named 't3' 71 type, extends(t3) :: t4 72 end type 73end 74subroutine r6 75 use :: m6, only: t5 => t1 76 type, extends(t5) :: t6 77 end type 78end 79 80module m7 81 type, private :: t1 82 integer :: i1 83 end type 84 type, extends(t1) :: t2 85 integer :: i2 86 integer, private :: i3 87 end type 88end 89subroutine s7 90 use m7 91 type(t2) :: x 92 integer :: j 93 j = x%i2 94 !ERROR: PRIVATE component 'i3' is only accessible within module 'm7' 95 j = x%i3 96 !ERROR: PRIVATE component 't1' is only accessible within module 'm7' 97 j = x%t1%i1 98end 99 100! 7.5.4.8(2) 101module m8 102 type :: t 103 integer :: i1 104 integer, private :: i2 105 end type 106 type(t) :: y 107 integer :: a(1) 108contains 109 subroutine s0 110 type(t) :: x 111 x = t(i1=2, i2=5) !OK 112 end 113 subroutine s1 114 a = [y%i2] !OK 115 end subroutine 116end 117subroutine s8 118 use m8 119 type(t) :: x 120 !ERROR: PRIVATE component 'i2' is only accessible within module 'm8' 121 x = t(2, 5) 122 !ERROR: PRIVATE component 'i2' is only accessible within module 'm8' 123 x = t(i1=2, i2=5) 124 !ERROR: PRIVATE component 'i2' is only accessible within module 'm8' 125 a = [y%i2] 126end 127 128! 7.5.4.8(2) 129module m9 130 interface 131 module subroutine s() 132 end subroutine 133 end interface 134 type :: t 135 integer :: i1 136 integer, private :: i2 137 end type 138end 139submodule(m9) sm8 140contains 141 module subroutine s 142 type(t) :: x 143 x = t(i1=2, i2=5) !OK 144 end 145end 146