[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349
[llvm-project.git] / flang / test / Semantics / resolve108.f90
blob15dd94a06160522f38f085697c60653b3c585181
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Tests attempts at forward references to local names in a FUNCTION prefix
4 ! This case is not an error, but will elicit bogus errors if the
5 ! result type of the function is badly resolved.
6 module m1
7 type t1
8 sequence
9 integer not_m
10 end type
11 contains
12 type(t1) function foo(n)
13 integer, intent(in) :: n
14 type t1
15 sequence
16 integer m
17 end type
18 foo%m = n
19 end function
20 end module
22 subroutine s1
23 use :: m1, only: foo
24 type t1
25 sequence
26 integer m
27 end type
28 type(t1) x
29 x = foo(234)
30 print *, x
31 end subroutine
33 module m2
34 integer, parameter :: k = kind(1.e0)
35 contains
36 real(kind=k) function foo(n)
37 integer, parameter :: k = kind(1.d0)
38 integer, intent(in) :: n
39 foo = n
40 end function
41 end module
43 subroutine s2
44 use :: m2, only: foo
45 !If we got the type of foo right, this declaration will fail
46 !due to an attempted division by zero.
47 !ERROR: Must be a constant value
48 integer, parameter :: test = 1 / (kind(foo(1)) - kind(1.e0))
49 end subroutine
51 module m3
52 integer, parameter :: k = kind(1.e0)
53 contains
54 real(kind=kind(x)) function foo(x)
55 !ERROR: The type of 'x' has already been implicitly declared
56 real(kind=kind(1.0d0)) x
57 foo = n
58 end function
59 end module
61 module m4
62 contains
63 !ERROR: Must be a constant value
64 real(n) function foo(x)
65 integer, parameter :: n = kind(foo)
66 real(n), intent(in) :: x
67 foo = x
68 end function
69 end module