You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using HasAnonUnionNonEscapable =HasAnonUnion<NonEscapable>;
146
+
using HasAnonStructNonEscapable = HasAnonStruct<NonEscapable>;
147
+
using NonEscapableHasAnonUnionNonEscapable =NonEscapableHasAnonUnion<NonEscapable>;
148
+
using NonEscapableOptional = std::optional<NonEscapable>;
149
+
118
150
//--- test.swift
119
151
import Test
120
152
import CxxStdlib
121
153
122
154
// CHECK: error: cannot find type 'Invalid' in scope
123
155
// CHECK: note: escapable record 'Invalid' cannot have non-escapable field 'v'
156
+
// CHECK-NO-LIFETIMES: error: cannot find type 'Invalid' in scope
157
+
// CHECK-NO-LIFETIMES: note: escapable record 'Invalid' cannot have non-escapable field 'v'
124
158
publicfunc importInvalid(_ x:Invalid){
125
159
}
126
160
127
161
// CHECK: error: a function with a ~Escapable result needs a parameter to depend on
128
-
// CHECK-NO-LIFETIMES: test.swift:11:32: error: a function cannot return a ~Escapable result
162
+
// CHECK-NO-LIFETIMES: test.swift:13:32: error: a function cannot return a ~Escapable result
129
163
publicfunc noAnnotations()->View{
130
-
// CHECK: nonescapable.h:24:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
131
-
// CHECK-NO-LIFETIMES: nonescapable.h:24:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
164
+
// CHECK: nonescapable.h:25:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
165
+
// CHECK-NO-LIFETIMES: nonescapable.h:25:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
132
166
f(nil)
133
-
// CHECK: nonescapable.h:28:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
134
-
// CHECK-NO-LIFETIMES: nonescapable.h:28:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
167
+
// CHECK: nonescapable.h:29:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
168
+
// CHECK-NO-LIFETIMES: nonescapable.h:29:7: warning: the returned type 'Owner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
135
169
// No duplicate warning for f2:
136
-
// CHECK-NOT: nonescapable.h:28
170
+
// CHECK-NOT: nonescapable.h:29
137
171
f2(nil,nil)
138
-
// CHECK: nonescapable.h:32:19: warning: the returned type 'TemplatedIntOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
139
-
// CHECK-NO-LIFETIMES: nonescapable.h:32:19: warning: the returned type 'TemplatedIntOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
172
+
// CHECK: nonescapable.h:33:19: warning: the returned type 'TemplatedIntOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
173
+
// CHECK-NO-LIFETIMES: nonescapable.h:33:19: warning: the returned type 'TemplatedIntOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
140
174
// No duplicate warning for f3:
141
-
// CHECK-NOT: nonescapable.h:32
175
+
// CHECK-NOT: nonescapable.h:33
142
176
f3(nil)
143
-
// CHECK: nonescapable.h:36:21: warning: the returned type 'TemplatedFloatOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
144
-
// CHECK-NO-LIFETIMES: nonescapable.h:36:21: warning: the returned type 'TemplatedFloatOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
177
+
// CHECK: nonescapable.h:37:21: warning: the returned type 'TemplatedFloatOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
178
+
// CHECK-NO-LIFETIMES: nonescapable.h:37:21: warning: the returned type 'TemplatedFloatOwner' is annotated as escapable; it cannot have lifetime dependencies [#ClangDeclarationImport]
145
179
// No duplicate warning for f4:
146
-
// CHECK-NOT: nonescapable.h:34
180
+
// CHECK-NOT: nonescapable.h:35
147
181
f4(nil)
148
-
// CHECK: nonescapable.h:40:6: warning: the returned type 'View' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport]
149
-
// CHECK-NO-LIFETIMES: nonescapable.h:40:6: warning: the returned type 'View' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport]
150
-
// CHECK-NO-LIFETIMES: nonescapable.h:40:6: error: a function cannot return a ~Escapable result
182
+
// CHECK: nonescapable.h:41:6: warning: the returned type 'View' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport]
183
+
// CHECK-NO-LIFETIMES: nonescapable.h:41:6: warning: the returned type 'View' is annotated as non-escapable; its lifetime dependencies must be annotated [#ClangDeclarationImport]
184
+
// CHECK-NO-LIFETIMES: nonescapable.h:41:6: error: a function cannot return a ~Escapable result
151
185
g(nil)
152
186
h1(nil)
153
-
// CHECK-NO-LIFETIMES: nonescapable.h:50:21: error: a function cannot return a ~Escapable result
154
-
h2(nil)
155
187
// CHECK-NO-LIFETIMES: nonescapable.h:51:21: error: a function cannot return a ~Escapable result
188
+
h2(nil)
189
+
// CHECK-NO-LIFETIMES: nonescapable.h:52:21: error: a function cannot return a ~Escapable result
156
190
h3(nil)
157
191
i1()
158
-
// CHECK: nonescapable.h:55:39: error: template parameter 'Missing' does not exist
159
-
// CHECK-NO-LIFETIMES: nonescapable.h:55:39: error: template parameter 'Missing' does not exist
192
+
// CHECK: nonescapable.h:56:39: error: template parameter 'Missing' does not exist
193
+
// CHECK-NO-LIFETIMES: nonescapable.h:56:39: error: template parameter 'Missing' does not exist
160
194
i2()
161
-
// CHECK: nonescapable.h:61:33: error: template parameter 'S' expected to be a type parameter
162
-
// CHECK-NO-LIFETIMES: nonescapable.h:61:33: error: template parameter 'S' expected to be a type parameter
195
+
// CHECK: nonescapable.h:62:33: error: template parameter 'S' expected to be a type parameter
196
+
// CHECK: nonescapable.h:80:41: error: a function with a ~Escapable result needs a parameter to depend on
197
+
// CHECK: note: '@_lifetime(immortal)' can be used to indicate that values produced
198
+
// CHECK-NO-LIFETIMES: nonescapable.h:62:33: error: template parameter 'S' expected to be a type parameter
163
199
j1()
164
-
// CHECK-NO-LIFETIMES: nonescapable.h:79:41: error: a function cannot return a ~Escapable result
165
-
j2()
166
200
// CHECK-NO-LIFETIMES: nonescapable.h:80:41: error: a function cannot return a ~Escapable result
201
+
j2()
202
+
// CHECK: nonescapable.h:81:41: error: a function with a ~Escapable result needs a parameter to depend on
203
+
// CHECK-NO-LIFETIMES: nonescapable.h:81:41: error: a function cannot return a ~Escapable result
204
+
// CHECK: note: '@_lifetime(immortal)' can be used to indicate that values produced
167
205
j3()
168
206
k1();
169
-
// CHECK-NO-LIFETIMES: nonescapable.h:86:15: error: a function cannot return a ~Escapable result
207
+
// CHECK: nonescapable.h:87:15: error: a function with a ~Escapable result needs a parameter to depend on
208
+
// CHECK: nonescapable.h:87:15: note: '@_lifetime(immortal)' can be used to indicate that values produced
209
+
// CHECK-NO-LIFETIMES: nonescapable.h:87:15: error: a function cannot return a ~Escapable result
210
+
170
211
k2();
171
-
// CHECK-NO-LIFETIMES: nonescapable.h:87:22: error: a function cannot return a ~Escapable result
212
+
// CHECK: nonescapable.h:88:22: error: a function with a ~Escapable result needs a parameter to depend on
213
+
// CHECK-NO-LIFETIMES: nonescapable.h:88:22: error: a function cannot return a ~Escapable result
214
+
// CHECK: note: '@_lifetime(immortal)' can be used to indicate that values produced
172
215
k3();
173
216
l1();
174
-
// CHECK: nonescapable.h:93:12: error: a function with a ~Escapable result needs a parameter to depend on
175
-
// CHECK-NO-LIFETIMES: nonescapable.h:93:12: error: a function cannot return a ~Escapable result
217
+
// CHECK: nonescapable.h:94:12: error: a function with a ~Escapable result needs a parameter to depend on
218
+
// CHECK: nonescapable.h:94:12: note: '@_lifetime(immortal)' can be used to indicate that values produced by this initializer have no lifetime dependencies
219
+
// CHECK-NO-LIFETIMES: nonescapable.h:94:12: error: a function cannot return a ~Escapable result
// CHECK-NO-LIFETIMES: note: return type unavailable (cannot import)
189
233
// CHECK-NO-LIFETIMES: pointer to non-escapable type 'View' cannot be imported
190
234
}
235
+
236
+
publicfunc anonymousUnions(){
237
+
_ =HasAnonUnionNonEscapable()
238
+
// CHECK: error: cannot find 'HasAnonUnionNonEscapable' in scope
239
+
// CHECK-NO-LIFETIMES: error: cannot find 'HasAnonUnionNonEscapable' in scope
240
+
_ =HasAnonStructNonEscapable()
241
+
// CHECK: error: cannot find 'HasAnonStructNonEscapable' in scope
242
+
// CHECK-NO-LIFETIMES: error: cannot find 'HasAnonStructNonEscapable' in scope
243
+
_ =NonEscapableHasAnonUnionNonEscapable()
244
+
_ =NonEscapableOptional()
245
+
// CHECK: error: cannot infer the lifetime dependence scope on an initializer with a ~Escapable parameter, specify '@_lifetime(borrow {{.*}})' or '@_lifetime(copy {{.*}})'
246
+
// CHECK-NO-LIFETIMES: error: an initializer cannot return a ~Escapable result
247
+
// CHECK-NO-LIFETIMES: error: an initializer cannot return a ~Escapable result
0 commit comments