File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed
test/Interop/Cxx/operators Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -2577,6 +2577,17 @@ namespace {
2577
2577
if (!dc)
2578
2578
return nullptr ;
2579
2579
2580
+ bool isOperator = decl->getDeclName ().getNameKind () ==
2581
+ clang::DeclarationName::CXXOperatorName;
2582
+ bool isNonSubscriptOperator =
2583
+ isOperator && (decl->getDeclName ().getCXXOverloadedOperator () !=
2584
+ clang::OO_Subscript);
2585
+
2586
+ // For now, we don't support non-subscript operators which are templated
2587
+ if (isNonSubscriptOperator && decl->isTemplated ()) {
2588
+ return nullptr ;
2589
+ }
2590
+
2580
2591
auto aliasedDecl =
2581
2592
Impl.importDecl (decl->getAliasedNamespace (), getActiveSwiftVersion ());
2582
2593
if (!aliasedDecl)
Original file line number Diff line number Diff line change @@ -186,11 +186,24 @@ template<class T> struct TemplatedArrayByVal {
186
186
T ts[];
187
187
T operator [](int i) { return ts[i]; }
188
188
};
189
+
189
190
typedef TemplatedArrayByVal<double > TemplatedDoubleArrayByVal;
190
191
191
- struct TemplatedSubscriptArrayByVal {
192
+ template <class T >
193
+ struct TemplatedByVal {
194
+ T val;
195
+ TemplatedByVal<T> operator +(TemplatedByVal other) {
196
+ return TemplatedByVal{.val = val + other.val };
197
+ }
198
+ };
199
+
200
+ struct TemplatedOperatorArrayByVal {
192
201
int *ptr;
193
202
template <class T > T operator [](T i) { return ptr[i]; }
203
+ template <class T >
204
+ T *operator +(T i) {
205
+ return ptr + i;
206
+ }
194
207
};
195
208
196
209
struct NonTrivial {
Original file line number Diff line number Diff line change 133
133
// CHECK: }
134
134
// CHECK: typealias TemplatedDoubleArrayByVal = __CxxTemplateInst19TemplatedArrayByValIdE
135
135
136
+ // CHECK: struct TemplatedByVal<T> {
137
+ // CHECK-NEXT: }
136
138
137
- // CHECK: struct TemplatedSubscriptArrayByVal {
139
+ // CHECK: struct TemplatedOperatorArrayByVal {
138
140
// CHECK: subscript(i: T) -> T { mutating get }
139
141
// CHECK: @available(*, unavailable, message: "use subscript")
140
142
// CHECK: mutating func __operatorSubscriptConst<T>(_ i: T) -> T
143
+ // CHECK-NOT: mutating func __operatorPlus<T>(_ i: T) -> UnsafeMutablePointer<T>
141
144
// CHECK: }
142
145
143
146
// CHECK: struct NonTrivialArrayByVal {
You can’t perform that action at this time.
0 commit comments