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