mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 18:21:16 +01:00
C++ interop: Don't crash when looking up names inside an incomplete C++ class/struct/union (#6096)
Only do the lookup when the class is complete. Before this change we crash in `Sema::LookupQualifiedName()` on `Declaration context must already be complete!`.
This commit is contained in:
@@ -2143,6 +2143,15 @@ auto ImportNameFromCpp(Context& context, SemIR::LocId loc_id,
|
||||
builder.Note(loc_id, InCppNameLookup, name_id);
|
||||
});
|
||||
|
||||
if (auto class_decl = context.insts().TryGetAs<SemIR::ClassDecl>(
|
||||
context.name_scopes().Get(scope_id).inst_id());
|
||||
class_decl.has_value()) {
|
||||
if (!context.types().IsComplete(
|
||||
context.classes().Get(class_decl->class_id).self_type_id)) {
|
||||
return SemIR::ScopeLookupResult::MakeError();
|
||||
}
|
||||
}
|
||||
|
||||
auto lookup = ClangLookupName(context, scope_id, name_id);
|
||||
if (!lookup) {
|
||||
SemIR::InstId builtin_inst_id =
|
||||
|
||||
Reference in New Issue
Block a user