Skip to content

Commit b96bcb4

Browse files
committed
[interop][SwiftToCxx] prohibit empty tuple param type
1 parent 57052f0 commit b96bcb4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

lib/IRGen/IRABIDetailsProvider.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ void LoweredFunctionSignature::visitParameterList(
302302
for (auto param : *FD->getParameters()) {
303303
// FIXME: tuples map to more than one sil param (but they're not yet
304304
// representable by the consumer).
305-
silParamMapping.push_back(param);
305+
if (!param->getInterfaceType()->isVoid())
306+
silParamMapping.push_back(param);
306307
}
307308
size_t currentSilParam = 0;
308309
for (const auto &abiParam : abiDetails.parameters) {

lib/PrintAsClang/PrintClangFunction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ class CFunctionSignatureTypePrinter
211211
if (TT->getNumElements() > 0)
212212
// FIXME: Handle non-void type.
213213
return ClangRepresentation::unsupported;
214+
// FIXME: how to support `()` parameters.
215+
if (typeUseKind != FunctionSignatureTypeUse::ReturnType)
216+
return ClangRepresentation::unsupported;
214217
os << "void";
215218
return ClangRepresentation::representable;
216219
}

test/Interop/SwiftToCxx/unsupported/unsupported-types-in-cxx.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
66

7-
// CHECK: takesFloat
8-
// CHECK-NOT: takesTuple
7+
// CHECK: takeFloat
8+
// CHECK-NOT: takes
99

10-
public func takesFloat(_ x: Float) {}
10+
public func takeFloat(_ x: Float) {}
1111

1212
public func takesTuple(_ x: (Float, Float)) {}
13+
14+
public func takesVoid(_ x: ()) {}

0 commit comments

Comments
 (0)