mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 09:01:05 +01:00
Require imported C++ types to be complete before creating a Core.Copy witness (#7106)
Fixes a crash that would occur due to `scope_id` of the class being unset.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "toolchain/check/import_ref.h"
|
||||
#include "toolchain/check/inst.h"
|
||||
#include "toolchain/check/type.h"
|
||||
#include "toolchain/check/type_completion.h"
|
||||
#include "toolchain/sem_ir/builtin_function_kind.h"
|
||||
#include "toolchain/sem_ir/ids.h"
|
||||
#include "toolchain/sem_ir/typed_insts.h"
|
||||
@@ -113,6 +114,17 @@ static auto BuildCopyWitness(
|
||||
return SemIR::InstId::None;
|
||||
}
|
||||
if (auto* class_decl = dyn_cast<clang::CXXRecordDecl>(tag_decl)) {
|
||||
auto class_type_id = SemIR::TypeId::ForTypeConstant(query_self_const_id);
|
||||
if (!Check::RequireCompleteType(
|
||||
context, class_type_id, SemIR::LocId::None, [&](auto& builder) {
|
||||
CARBON_DIAGNOSTIC(IncompleteTypeInCopyWitness, Context,
|
||||
"argument to C++ call has incomplete type {0}",
|
||||
SemIR::TypeId);
|
||||
builder.Context(loc_id, IncompleteTypeInCopyWitness,
|
||||
class_type_id);
|
||||
})) {
|
||||
return SemIR::ErrorInst::InstId;
|
||||
}
|
||||
auto decl_info = DeclInfo{.decl = clang_sema.LookupCopyingConstructor(
|
||||
class_decl, clang::Qualifiers::Const),
|
||||
.signature = {.num_params = 1}};
|
||||
|
||||
Reference in New Issue
Block a user