Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / local-vs-global.f90
blobd903e431f2ae2d88f5b619232c1b86d4725d5c82
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
3 module module_before_1
4 end
6 module module_before_2
7 end
9 block data block_data_before_1
10 end
12 block data block_data_before_2
13 end
15 subroutine explicit_before_1(a)
16 real, optional :: a
17 end
19 subroutine explicit_before_2(a)
20 real, optional :: a
21 end
23 subroutine implicit_before_1(a)
24 real :: a
25 end
27 subroutine implicit_before_2(a)
28 real :: a
29 end
31 function explicit_func_before_1(a)
32 real, optional :: a
33 end
35 function explicit_func_before_2(a)
36 real, optional :: a
37 end
39 function implicit_func_before_1(a)
40 real :: a
41 end
43 function implicit_func_before_2(a)
44 real :: a
45 end
47 program test
48 external justfine ! OK to name a BLOCK DATA if not called
49 !ERROR: The global entity 'module_before_1' corresponding to the local procedure 'module_before_1' is not a callable subprogram
50 external module_before_1
51 !ERROR: The global entity 'block_data_before_1' corresponding to the local procedure 'block_data_before_1' is not a callable subprogram
52 external block_data_before_1
53 !ERROR: The global subprogram 'explicit_before_1' may not be referenced via the implicit interface 'explicit_before_1'
54 external explicit_before_1
55 external implicit_before_1
56 !ERROR: The global subprogram 'explicit_func_before_1' may not be referenced via the implicit interface 'explicit_func_before_1'
57 external explicit_func_before_1
58 external implicit_func_before_1
59 !ERROR: The global entity 'module_after_1' corresponding to the local procedure 'module_after_1' is not a callable subprogram
60 external module_after_1
61 !ERROR: The global entity 'block_data_after_1' corresponding to the local procedure 'block_data_after_1' is not a callable subprogram
62 external block_data_after_1
63 !ERROR: The global subprogram 'explicit_after_1' may not be referenced via the implicit interface 'explicit_after_1'
64 external explicit_after_1
65 external implicit_after_1
66 !ERROR: The global subprogram 'explicit_func_after_1' may not be referenced via the implicit interface 'explicit_func_after_1'
67 external explicit_func_after_1
68 external implicit_func_after_1
69 call module_before_1
70 !ERROR: 'module_before_2' is not a callable procedure
71 call module_before_2
72 call block_data_before_1
73 !ERROR: 'block_data_before_2' is not a callable procedure
74 call block_data_before_2
75 call explicit_before_1(1.)
76 !ERROR: References to the procedure 'explicit_before_2' require an explicit interface
77 call explicit_before_2(1.)
78 !WARNING: If the procedure's interface were explicit, this reference would be in error
79 !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
80 call implicit_before_1
81 !WARNING: If the procedure's interface were explicit, this reference would be in error
82 !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
83 call implicit_before_2
84 print *, explicit_func_before_1(1.)
85 !ERROR: References to the procedure 'explicit_func_before_2' require an explicit interface
86 print *, explicit_func_before_2(1.)
87 !WARNING: If the procedure's interface were explicit, this reference would be in error
88 !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
89 print *, implicit_func_before_1()
90 !WARNING: If the procedure's interface were explicit, this reference would be in error
91 !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
92 print *, implicit_func_before_2()
93 call module_after_1
94 call module_after_2
95 call block_data_after_1
96 call block_data_after_2
97 call explicit_after_1(1.)
98 !ERROR: References to the procedure 'explicit_after_2' require an explicit interface
99 call explicit_after_2(1.)
100 !WARNING: If the procedure's interface were explicit, this reference would be in error
101 !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
102 call implicit_after_1
103 !WARNING: If the procedure's interface were explicit, this reference would be in error
104 !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
105 call implicit_after_2
106 print *, explicit_func_after_1(1.)
107 !ERROR: References to the procedure 'explicit_func_after_2' require an explicit interface
108 print *, explicit_func_after_2(1.)
109 !WARNING: If the procedure's interface were explicit, this reference would be in error
110 !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
111 print *, implicit_func_after_1()
112 !WARNING: If the procedure's interface were explicit, this reference would be in error
113 !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
114 print *, implicit_func_after_2()
115 end program
117 block data justfine
120 module module_after_1
123 !ERROR: 'module_after_2' is already declared in this scoping unit
124 module module_after_2
127 block data block_data_after_1
130 !ERROR: BLOCK DATA 'block_data_after_2' has been called
131 block data block_data_after_2
134 subroutine explicit_after_1(a)
135 real, optional :: a
138 subroutine explicit_after_2(a)
139 real, optional :: a
142 subroutine implicit_after_1(a)
143 real :: a
146 subroutine implicit_after_2(a)
147 real :: a
150 function explicit_func_after_1(a)
151 real, optional :: a
154 function explicit_func_after_2(a)
155 real, optional :: a
158 function implicit_func_after_1(a)
159 real :: a
162 function implicit_func_after_2(a)
163 real :: a