1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
3 ! Error tests for structure constructors: C1594 violations
4 ! from assigning globally-visible data to POINTER components.
5 ! This test is structconst03.f90 with the type parameters removed.
8 real, target
:: usedfrom1
16 type(has_pointer1
), allocatable
:: link1
! don't loop during analysis
19 type(has_pointer1
) :: pnested
20 type(has_pointer2
), allocatable
:: link2
22 type, extends(has_pointer2
) :: has_pointer3
23 type(has_pointer3
), allocatable
:: link3
27 type(t1
), allocatable
:: link
30 type(has_pointer1
) :: hp1
31 type(t2
), allocatable
:: link
34 type(has_pointer2
) :: hp2
35 type(t3
), allocatable
:: link
38 type(has_pointer3
) :: hp3
39 type(t4
), allocatable
:: link
41 real, target
:: modulevar1
42 type(has_pointer1
) :: modulevar2
43 type(has_pointer2
) :: modulevar3
44 type(has_pointer3
) :: modulevar4
48 pure
subroutine ps1(dummy1
, dummy2
, dummy3
, dummy4
)
49 real, target
:: local1
54 real, intent(in
), target
:: dummy1
55 real, intent(inout
), target
:: dummy2
56 real, pointer :: dummy3
57 real, intent(inout
), target
:: dummy4
[*]
58 real, target
:: commonvar1
59 common /cblock
/ commonvar1
61 !ERROR: Externally visible object 'usedfrom1' may not be associated with pointer component 'pt1' in a pure procedure
63 !ERROR: Externally visible object 'modulevar1' may not be associated with pointer component 'pt1' in a pure procedure
65 !ERROR: Externally visible object 'cblock' may not be associated with pointer component 'pt1' in a pure procedure
67 !ERROR: Externally visible object 'dummy1' may not be associated with pointer component 'pt1' in a pure procedure
71 ! TODO when semantics handles coindexing:
72 ! TODO !ERROR: Externally visible object may not be associated with a pointer in a pure procedure
73 ! TODO x1 = t1(dummy4[0])
75 !ERROR: Externally visible object 'modulevar2' may not be associated with pointer component 'ptop' in a pure procedure
77 !ERROR: Externally visible object 'modulevar3' may not be associated with pointer component 'ptop' in a pure procedure
79 !ERROR: Externally visible object 'modulevar4' may not be associated with pointer component 'ptop' in a pure procedure
82 pure
subroutine subr(dummy1a
, dummy2a
, dummy3a
, dummy4a
)
83 real, target
:: local1a
88 real, intent(in
), target
:: dummy1a
89 real, intent(inout
), target
:: dummy2a
90 real, pointer :: dummy3a
91 real, intent(inout
), target
:: dummy4a
[*]
93 !ERROR: Externally visible object 'usedfrom1' may not be associated with pointer component 'pt1' in a pure procedure
95 !ERROR: Externally visible object 'modulevar1' may not be associated with pointer component 'pt1' in a pure procedure
97 !ERROR: Externally visible object 'commonvar1' may not be associated with pointer component 'pt1' in a pure procedure
99 !ERROR: Externally visible object 'dummy1' may not be associated with pointer component 'pt1' in a pure procedure
101 !ERROR: Externally visible object 'dummy1a' may not be associated with pointer component 'pt1' in a pure procedure
106 ! TODO when semantics handles coindexing:
107 ! TODO !ERROR: Externally visible object may not be associated with a pointer in a pure procedure
108 ! TODO x1a = t1(dummy4a[0])
110 !ERROR: Externally visible object 'modulevar2' may not be associated with pointer component 'ptop' in a pure procedure
112 !ERROR: Externally visible object 'modulevar3' may not be associated with pointer component 'ptop' in a pure procedure
114 !ERROR: Externally visible object 'modulevar4' may not be associated with pointer component 'ptop' in a pure procedure
119 pure
integer function pf1(dummy3
)
120 real, pointer :: dummy3
122 !ERROR: Externally visible object 'dummy3' may not be associated with pointer component 'pt1' in a pure procedure
125 pure
subroutine subr(dummy3a
)
126 real, pointer :: dummy3a
128 !ERROR: Externally visible object 'dummy3' may not be associated with pointer component 'pt1' in a pure procedure
134 impure
real function ipf1(dummy1
, dummy2
, dummy3
, dummy4
)
135 real, target
:: local1
140 real, intent(in
), target
:: dummy1
141 real, intent(inout
), target
:: dummy2
142 real, pointer :: dummy3
143 real, intent(inout
), target
:: dummy4
[*]
144 real, target
:: commonvar1
145 common /cblock
/ commonvar1
154 ! TODO when semantics handles coindexing:
155 ! TODO x1 = t1(dummy4[0])