Skip to content

Commit 57c0fde

Browse files
authored
Fix C++ thunk triggering for functions with default args which return a simple type (carbon-language#6152)
Before this change, we wrongly ignore the decision to generate a thunk for a function with default args by overriding this decision with the fact the return type by itself doesn't require a thunk. This causes not generating a thunk which leads to crashing in lowering. Add tests that show that now thunk is generated in `check` and it no longer crashes in `lower`. Follow up of carbon-language#6108.
1 parent 16999a7 commit 57c0fde

File tree

3 files changed

+491
-295
lines changed

3 files changed

+491
-295
lines changed

toolchain/check/cpp/thunk.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ auto IsCppThunkRequired(Context& context, const SemIR::Function& function)
120120
if (return_type_id == SemIR::ErrorInst::TypeId) {
121121
return false;
122122
}
123-
thunk_required = IsThunkRequiredForType(context, return_type_id);
123+
thunk_required =
124+
thunk_required || IsThunkRequiredForType(context, return_type_id);
124125
}
125126

126127
for (auto param_id :

0 commit comments

Comments
 (0)