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