Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / symbol03.f90
bloba6b4b0bd1593704caccc905149066e4a5c832baa
1 ! RUN: %python %S/test_symbols.py %s %flang_fc1
2 ! Test host association in internal subroutine of main program.
4 !DEF: /main MainProgram
5 program main
6 !DEF: /main/x ObjectEntity INTEGER(4)
7 integer x
8 !DEF: /main/s (Subroutine) Subprogram
9 call s
10 contains
11 !REF: /main/s
12 subroutine s
13 !DEF: /main/s/y (Implicit) ObjectEntity REAL(4)
14 !DEF: /main/s/x HostAssoc INTEGER(4)
15 y = x
16 contains
17 !DEF: /main/s/s2 (Subroutine) Subprogram
18 subroutine s2
19 !DEF: /main/s/s2/z (Implicit) ObjectEntity REAL(4)
20 !DEF: /main/s/s2/x HostAssoc INTEGER(4)
21 z = x
22 end subroutine
23 end subroutine
24 end program
26 !DEF: /s (Subroutine) Subprogram
27 subroutine s
28 !DEF: /s/x ObjectEntity REAL(4)
29 real x(100, 100)
30 !DEF: /s/s1 (Subroutine) Subprogram
31 call s1
32 contains
33 !REF: /s/s1
34 subroutine s1
35 !DEF: /s/s1/x HostAssoc REAL(4)
36 print *, x(10, 10)
37 end subroutine
38 end subroutine
40 !DEF: /sb (Subroutine) Subprogram
41 subroutine sb
42 !DEF: /sb/x TARGET ObjectEntity REAL(4)
43 real, target :: x
44 !DEF: /sb/s1 (Subroutine) Subprogram
45 call s1
46 contains
47 !REF: /sb/s1
48 subroutine s1
49 !DEF: /sb/s1/p POINTER ObjectEntity REAL(4)
50 real, pointer :: p
51 !REF: /sb/s1/p
52 !DEF: /sb/s1/x TARGET HostAssoc REAL(4)
53 p => x
54 end subroutine
55 end subroutine
57 ! Test host associated symbols are also created for symbols that are use
58 ! associated in the host.
60 !DEF: /m1 Module
61 module m1
62 !DEF: /m1/x PUBLIC ObjectEntity REAL(4)
63 real x(100,100)
64 !DEF: /m1/x_target PUBLIC, TARGET ObjectEntity REAL(4)
65 real, target :: x_target
66 end module
68 !DEF: /s_use (Subroutine) Subprogram
69 subroutine s_use
70 !REF: /m1
71 use :: m1
72 !DEF: /s_use/x Use REAL(4)
73 print *, x
74 !DEF: /s_use/s1 (Subroutine) Subprogram
75 call s1
76 contains
77 !REF: /s_use/s1
78 subroutine s1
79 !DEF: /s_use/s1/x HostAssoc REAL(4)
80 print *, x(10,10)
81 end subroutine
82 end subroutine
84 !DEF: /sb_use (Subroutine) Subprogram
85 subroutine sb_use
86 !REF: /m1
87 use :: m1
88 !DEF: /sb_use/x_target TARGET Use REAL(4)
89 print *, x_target
90 !DEF: /sb_use/s1 (Subroutine) Subprogram
91 call s1
92 contains
93 !REF: /sb_use/s1
94 subroutine s1
95 !DEF: /sb_use/s1/p POINTER ObjectEntity REAL(4)
96 real, pointer :: p
97 !REF: /sb_use/s1/p
98 !DEF: /sb_use/s1/x_target TARGET HostAssoc REAL(4)
99 p => x_target
100 end subroutine
101 end subroutine