Skip to content

Commit 5537b72

Browse files
committed
[cxx-interop] Bail on dependent reference types. We don't know how to handle those yet.
1 parent f93bc64 commit 5537b72

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,12 @@ namespace {
546546
return importFunctionPointerLikeType(*type, pointeeType);
547547
}
548548

549+
// Currently, we can't generate thunks for references to dependent types
550+
// because there's no way to cast without a copy (without writing the SIL
551+
// manually).
552+
if (pointeeQualType->isDependentType())
553+
return Type();
554+
549555
if (Impl.isOverAligned(pointeeQualType)) {
550556
return importOverAlignedFunctionPointerLikeType(*type, Impl);
551557
}

test/Interop/Cxx/reference/Inputs/reference.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ void setConstStaticIntRvalueRef(const int &&);
1616
auto getFuncRef() -> int (&)();
1717
auto getFuncRvalueRef() -> int (&&)();
1818

19+
template<class T>
20+
struct ClassTemplate {};
21+
22+
template<class T>
23+
const ClassTemplate<T> &refToDependent() { return ClassTemplate<T>(); }
24+
1925
// We cannot import "_Atomic" types. Make sure we fail gracefully instead of
2026
// crashing when we have an "_Atomic" type or a reference to one.
2127
void dontImportAtomicRef(_Atomic(int)&) { }

test/Interop/Cxx/reference/reference-module-interface.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
// CHECK: func getFuncRef() -> @convention(c) () -> Int32
1414
// CHECK: func getFuncRvalueRef() -> @convention(c) () -> Int32
1515

16+
// CHECK-NOT: refToDependent
1617
// CHECK-NOT: dontImportAtomicRef

0 commit comments

Comments
 (0)