Skip to content

Commit 6e69918

Browse files
committed
[cxx-interop] Bail on functions that use unimportable types.
We already fixed this for "global" functions. This is a more generic solution that works for "nested" functions as well. (Members or functions in a namespace.)
1 parent 887464b commit 6e69918

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
@@ -3888,6 +3888,10 @@ namespace {
38883888
bodyParams =
38893889
getNonSelfParamList(dc, decl, selfIdx, name.getArgumentNames(),
38903890
allowNSUIntegerAsInt, !name, templateParams);
3891+
// If we can't import a param for some reason (ex. it's a dependent
3892+
// type), bail.
3893+
if (!bodyParams)
3894+
return nullptr;
38913895

38923896
importedType =
38933897
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
@@ -64,4 +64,19 @@ void cassini(T, U) { }
6464
template<class T>
6565
void magellan(T&) { }
6666

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

0 commit comments

Comments
 (0)