[AMDGPU] Assert if stack grows downwards. (#119888)
[llvm-project.git] / flang / test / Semantics / resolve77.f90
blob0133fac3bfbc5db978c09e754baf6cf28459da4d
1 ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2 ! Tests valid and invalid usage of forward references to procedures
3 ! in specification expressions.
4 module m
5 interface ifn2
6 module procedure if2
7 end interface
8 interface ifn3
9 module procedure if3
10 end interface
11 !ERROR: Automatic data object 'a' may not appear in a module
12 real :: a(if1(1))
13 !ERROR: Automatic data object 'b' may not appear in a module
14 real :: b(ifn2(1))
15 !ERROR: Automatic data object 'c' may not appear in COMMON block /blk/
16 real :: c(if1(1))
17 !ERROR: Automatic data object 'd' may not appear in COMMON block //
18 real :: d(ifn2(1))
19 common /blk/c
20 common d
21 contains
22 subroutine t1(n)
23 integer :: iarr(if1(n))
24 end subroutine
25 pure integer function if1(n)
26 integer, intent(in) :: n
27 if1 = n
28 end function
29 subroutine t2(n)
30 integer :: iarr(ifn3(n)) ! should resolve to if3
31 end subroutine
32 pure integer function if2(n)
33 integer, intent(in) :: n
34 if2 = n
35 end function
36 pure integer function if3(n)
37 integer, intent(in) :: n
38 if3 = n
39 end function
40 end module
42 subroutine nester
43 !ERROR: The internal function 'if1' may not be referenced in a specification expression
44 real :: a(if1(1))
45 contains
46 subroutine t1(n)
47 !ERROR: The internal function 'if2' may not be referenced in a specification expression
48 integer :: iarr(if2(n))
49 end subroutine
50 pure integer function if1(n)
51 integer, intent(in) :: n
52 if1 = n
53 end function
54 pure integer function if2(n)
55 integer, intent(in) :: n
56 if2 = n
57 end function
58 end subroutine
60 block data
61 common /blk2/ n
62 data n/100/
63 !PORTABILITY: specification expression refers to local object 'n' (initialized and saved)
64 !ERROR: Automatic data object 'a' may not appear in a BLOCK DATA subprogram
65 real a(n)
66 end
68 program main
69 common /blk2/ n
70 !PORTABILITY: Automatic data object 'a' should not appear in the specification part of a main program
71 real a(n)
72 end