Skip to content

Commit 2b0ff64

Browse files
authored
Merge pull request swiftlang#34870 from zoecarver/cxx/fix/no-params
[cxx-interop] Bail on functions that use unimportable types.
2 parents 8fc2598 + 6e69918 commit 2b0ff64

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3890,6 +3890,10 @@ namespace {
38903890
bodyParams =
38913891
getNonSelfParamList(dc, decl, selfIdx, name.getArgumentNames(),
38923892
allowNSUIntegerAsInt, !name, templateParams);
3893+
// If we can't import a param for some reason (ex. it's a dependent
3894+
// type), bail.
3895+
if (!bodyParams)
3896+
return nullptr;
38933897

38943898
importedType =
38953899
Impl.importFunctionReturnType(dc, decl, allowNSUIntegerAsInt);

test/Interop/Cxx/templates/Inputs/function-templates.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,19 @@ void cassini(T, U) { }
6969
template<class T>
7070
void magellan(T&) { }
7171

72-
}
72+
} // namespace Orbiters
73+
74+
// We can't import these (and may never be able to in the case of "_Atomic"),
75+
// but don't crash while trying.
76+
namespace Unimportable {
77+
78+
template <class> struct Dependent {};
79+
template <class T> void takesDependent(Dependent<T> d) {}
80+
81+
void takesAtomic(_Atomic(int) a) {}
82+
83+
struct HasImposibleMember {
84+
void memberTakesAtomic(_Atomic(int) a) {}
85+
};
86+
87+
} // namespace Unimportable

0 commit comments

Comments
 (0)