C++ interop: Correctly report the unsupported param type when using explicit object param (#6179)

This fixes a bug, which seems to have been introduced in #6108.

In the new test, without this change, we will diagnose with
```
error: semantics TODO: `Unsupported: parameter type: ExplicitObjectParam` [SemanticsTodo]
```
This commit is contained in:
Boaz Brickner
2025-10-08 17:01:11 +00:00
committed by GitHub
parent fd74e49fd2
commit c254e9fd75
2 changed files with 24 additions and 8 deletions
+6 -8
View File
@@ -1365,14 +1365,13 @@ static auto MakeParamPatternsBlockId(Context& context, SemIR::LocId loc_id,
clang_decl.getType()->castAs<clang::FunctionProtoType>();
for (int i : llvm::seq(num_params)) {
const auto* param = clang_decl.getNonObjectParameter(i);
clang::QualType orig_param_type = function_type->getParamType(
clang_decl.hasCXXExplicitFunctionObjectParameter() + i);
// The parameter type is decayed but hasn't necessarily had its qualifiers
// removed.
// TODO: The presence of qualifiers here is probably a Clang bug.
clang::QualType param_type =
function_type
->getParamType(clang_decl.hasCXXExplicitFunctionObjectParameter() +
i)
.getUnqualifiedType();
clang::QualType param_type = orig_param_type.getUnqualifiedType();
// We map `T&` parameters to `addr param: T*`, and `T&&` parameters to
// `param: T`.
@@ -1391,9 +1390,8 @@ static auto MakeParamPatternsBlockId(Context& context, SemIR::LocId loc_id,
EndSubpatternAsExpr(context, orig_type_inst_id);
if (!type_id.has_value()) {
context.TODO(loc_id,
llvm::formatv("Unsupported: parameter type: {0}",
function_type->getParamType(i).getAsString()));
context.TODO(loc_id, llvm::formatv("Unsupported: parameter type: {0}",
orig_param_type.getAsString()));
return SemIR::InstBlockId::None;
}