File: resolve34.f90

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (166 lines) | stat: -rw-r--r-- 3,091 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
! RUN: %python %S/test_errors.py %s %flang_fc1
! Extended derived types

module m1
  type :: t1
    integer :: x
    !ERROR: Component 'x' is already declared in this derived type
    real :: x
  end type
end

module m2
  type :: t1
    integer :: i
  end type
  type, extends(t1) :: t2
    !ERROR: Component 'i' is already declared in a parent of this derived type
    integer :: i
  end type
end

module m3
  type :: t1
  end type
  type, extends(t1) :: t2
    integer :: i
    !ERROR: 't1' is a parent type of this type and so cannot be a component
    real :: t1
  end type
  type :: t3
  end type
  type, extends(t3) :: t4
  end type
  type, extends(t4) :: t5
    !ERROR: 't3' is a parent type of this type and so cannot be a component
    real :: t3
  end type
end

module m4
  type :: t1
    integer :: t1
  end type
  !ERROR: Type cannot be extended as it has a component named 't1'
  type, extends(t1) :: t2
  end type
end

module m5
  type :: t1
    integer :: t2
  end type
  type, extends(t1) :: t2
  end type
  !ERROR: Type cannot be extended as it has a component named 't2'
  type, extends(t2) :: t3
  end type
end

module m6
  ! t1 can be extended if it is known as anything but t3
  type :: t1
    integer :: t3
  end type
  type, extends(t1) :: t2
  end type
end
subroutine s6
  use :: m6, only: t3 => t1
  !ERROR: Type cannot be extended as it has a component named 't3'
  type, extends(t3) :: t4
  end type
end
subroutine r6
  use :: m6, only: t5 => t1
  type, extends(t5) :: t6
  end type
end

module m7
  type, private :: t1
    integer :: i1
  end type
  type, extends(t1) :: t2
    integer :: i2
    integer, private :: i3
  end type
end
subroutine s7
  use m7
  type(t2) :: x
  integer :: j
  j = x%i2
  !ERROR: PRIVATE name 'i3' is only accessible within module 'm7'
  j = x%i3
  !ERROR: PRIVATE name 't1' is only accessible within module 'm7'
  j = x%t1%i1
end

! 7.5.4.8(2)
module m8
  type  :: t
    integer :: i1
    integer, private :: i2
  end type
  type(t) :: y
  integer :: a(1)
contains
  subroutine s0
    type(t) :: x
    x = t(i1=2, i2=5)  !OK
  end
  subroutine s1
    a = [y%i2]  !OK
  end subroutine
end
subroutine s8
  use m8
  type(t) :: x
  !ERROR: PRIVATE name 'i2' is only accessible within module 'm8'
  x = t(2, 5)
  !ERROR: PRIVATE name 'i2' is only accessible within module 'm8'
  x = t(i1=2, i2=5)
  !ERROR: PRIVATE name 'i2' is only accessible within module 'm8'
  a = [y%i2]
end

! 7.5.4.8(2)
module m9
  interface
    module subroutine s()
    end subroutine
  end interface
  type  :: t
    integer :: i1
    integer, private :: i2
  end type
end
submodule(m9) sm8
contains
  module subroutine s
    type(t) :: x
    x = t(i1=2, i2=5)  !OK
  end
end

module m10
  type t
    integer n
   contains
    procedure :: f
    generic, private :: operator(+) => f
  end type
 contains
  type(t) function f(x,y)
    class(t), intent(in) :: x, y
    f = t(x%n + y%n)
  end function
end module
subroutine s10
  use m10
  type(t) x
  x = t(1)
  !ERROR: PRIVATE name 'operator(+)' is only accessible within module 'm10'
  x = x + x
end subroutine