1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Error tests for structure constructors: C1594 violations
3 ! from assigning globally-visible data to POINTER components.
4 ! This test is structconst03.f90 with the type parameters removed.
7 real, target
:: usedfrom1
15 type(has_pointer1
), allocatable
:: link1
! don't loop during analysis
18 type(has_pointer1
) :: pnested
19 type(has_pointer2
), allocatable
:: link2
21 type, extends(has_pointer2
) :: has_pointer3
22 type(has_pointer3
), allocatable
:: link3
26 type(t1
), allocatable
:: link
29 type(has_pointer1
) :: hp1
30 type(t2
), allocatable
:: link
33 type(has_pointer2
) :: hp2
34 type(t3
), allocatable
:: link
37 type(has_pointer3
) :: hp3
38 type(t4
), allocatable
:: link
40 real, target
:: modulevar1
41 type(has_pointer1
) :: modulevar2
42 type(has_pointer2
) :: modulevar3
43 type(has_pointer3
) :: modulevar4
47 pure
subroutine ps1(dummy1
, dummy2
, dummy3
, dummy4
)
48 real, target
:: local1
53 real, intent(in
), target
:: dummy1
54 real, intent(inout
), target
:: dummy2
55 real, pointer :: dummy3
56 real, intent(inout
), target
:: dummy4
[*]
57 real, target
:: commonvar1
58 common /cblock
/ commonvar1
60 !ERROR: Externally visible object 'usedfrom1' may not be associated with pointer component 'pt1' in a pure procedure
62 !ERROR: Externally visible object 'modulevar1' may not be associated with pointer component 'pt1' in a pure procedure
64 !ERROR: Externally visible object 'cblock' may not be associated with pointer component 'pt1' in a pure procedure
66 !ERROR: Externally visible object 'dummy1' may not be associated with pointer component 'pt1' in a pure procedure
70 ! TODO when semantics handles coindexing:
71 ! TODO !ERROR: Externally visible object may not be associated with a pointer in a pure procedure
72 ! TODO x1 = t1(dummy4[0])
74 !ERROR: Externally visible object 'modulevar2' may not be associated with pointer component 'ptop' in a pure procedure
76 !ERROR: Externally visible object 'modulevar3' may not be associated with pointer component 'ptop' in a pure procedure
78 !ERROR: Externally visible object 'modulevar4' may not be associated with pointer component 'ptop' in a pure procedure
81 pure
subroutine subr(dummy1a
, dummy2a
, dummy3a
, dummy4a
)
82 real, target
:: local1a
87 real, intent(in
), target
:: dummy1a
88 real, intent(inout
), target
:: dummy2a
89 real, pointer :: dummy3a
90 real, intent(inout
), target
:: dummy4a
[*]
92 !ERROR: Externally visible object 'usedfrom1' may not be associated with pointer component 'pt1' in a pure procedure
94 !ERROR: Externally visible object 'modulevar1' may not be associated with pointer component 'pt1' in a pure procedure
96 !ERROR: Externally visible object 'commonvar1' may not be associated with pointer component 'pt1' in a pure procedure
98 !ERROR: Externally visible object 'dummy1' may not be associated with pointer component 'pt1' in a pure procedure
100 !ERROR: Externally visible object 'dummy1a' may not be associated with pointer component 'pt1' in a pure procedure
105 ! TODO when semantics handles coindexing:
106 ! TODO !ERROR: Externally visible object may not be associated with a pointer in a pure procedure
107 ! TODO x1a = t1(dummy4a[0])
109 !ERROR: Externally visible object 'modulevar2' may not be associated with pointer component 'ptop' in a pure procedure
111 !ERROR: Externally visible object 'modulevar3' may not be associated with pointer component 'ptop' in a pure procedure
113 !ERROR: Externally visible object 'modulevar4' may not be associated with pointer component 'ptop' in a pure procedure
118 pure
integer function pf1(dummy3
)
119 real, pointer :: dummy3
121 !ERROR: Externally visible object 'dummy3' may not be associated with pointer component 'pt1' in a pure procedure
124 pure
subroutine subr(dummy3a
)
125 real, pointer :: dummy3a
127 !ERROR: Externally visible object 'dummy3' may not be associated with pointer component 'pt1' in a pure procedure
133 impure
real function ipf1(dummy1
, dummy2
, dummy3
, dummy4
)
134 real, target
:: local1
139 real, intent(in
), target
:: dummy1
140 real, intent(inout
), target
:: dummy2
141 real, pointer :: dummy3
142 real, intent(inout
), target
:: dummy4
[*]
143 real, target
:: commonvar1
144 common /cblock
/ commonvar1
153 ! TODO when semantics handles coindexing:
154 ! TODO x1 = t1(dummy4[0])