[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349
[llvm-project.git] / flang / test / Semantics / resolve09.f90
blob2954b146374dad8eec09d6c1ccb1954624d14310
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 integer :: y
3 procedure() :: a
4 procedure(real) :: b
5 call a ! OK - can be function or subroutine
6 !ERROR: Cannot call subroutine 'a' like a function
7 c = a()
8 !ERROR: Cannot call function 'b' like a subroutine
9 call b
10 !ERROR: Cannot call function 'y' like a subroutine
11 call y
12 call x
13 !ERROR: Cannot call subroutine 'x' like a function
14 z = x()
15 end
17 subroutine s
18 !ERROR: Cannot call function 'f' like a subroutine
19 call f
20 !ERROR: Cannot call subroutine 's' like a function
21 !ERROR: Function result characteristics are not known
22 i = s()
23 contains
24 function f()
25 end
26 end
28 subroutine s2
29 ! subroutine vs. function is determined by use
30 external :: a, b
31 call a()
32 !ERROR: Cannot call subroutine 'a' like a function
33 x = a()
34 x = b()
35 !ERROR: Cannot call function 'b' like a subroutine
36 call b()
37 end
39 subroutine s3
40 ! subroutine vs. function is determined by use, even in internal subprograms
41 external :: a
42 procedure() :: b
43 contains
44 subroutine s3a()
45 x = a()
46 call b()
47 end
48 subroutine s3b()
49 !ERROR: Cannot call function 'a' like a subroutine
50 call a()
51 !ERROR: Cannot call subroutine 'b' like a function
52 x = b()
53 end
54 end
56 module m
57 ! subroutine vs. function is determined at end of specification part
58 external :: a
59 procedure() :: b
60 contains
61 subroutine s()
62 call a()
63 !ERROR: Cannot call subroutine 'b' like a function
64 x = b()
65 end
66 end
68 ! Call to entity in global scope, even with IMPORT, NONE
69 subroutine s4
70 block
71 import, none
72 integer :: i
73 !ERROR: 'm' is not a callable procedure
74 i = m()
75 !ERROR: 'm' is not a callable procedure
76 call m()
77 end block
78 end
80 ! Call to entity in global scope, even with IMPORT, NONE
81 subroutine s5
82 block
83 import, none
84 integer :: i
85 i = foo()
86 !ERROR: Cannot call function 'foo' like a subroutine
87 call foo()
88 end block
89 end
91 subroutine s6
92 call a6()
93 end
94 !ERROR: 'a6' was previously called as a subroutine
95 function a6()
96 a6 = 0.0
97 end
99 subroutine s7
100 x = a7()
102 !ERROR: 'a7' was previously called as a function
103 subroutine a7()
106 !OK: use of a8 and b8 is consistent
107 subroutine s8
108 call a8()
109 x = b8()
111 subroutine a8()
113 function b8()
114 b8 = 0.0