mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 08:51:04 +01:00
Recover better from invalid C++ classes. (#5992)
When importing a class definition, don't ask for the class layout if the definition is invalid. Avoids an assertion failure in Clang. --------- Co-authored-by: Dana Jansens <danakj@orodu.net>
This commit is contained in:
co-authored by
Dana Jansens
parent
00d0eb85e2
commit
4483d1e5a7
@@ -825,6 +825,11 @@ static auto ImportClassObjectRepr(Context& context, SemIR::ClassId class_id,
|
||||
SemIR::TypeInstId class_type_inst_id,
|
||||
const clang::CXXRecordDecl* clang_def)
|
||||
-> SemIR::TypeInstId {
|
||||
if (clang_def->isInvalidDecl()) {
|
||||
// Clang already diagnosed this error.
|
||||
return SemIR::ErrorInst::TypeInstId;
|
||||
}
|
||||
|
||||
// For now, if the class is empty, produce an empty struct as the object
|
||||
// representation. This allows our tests to continue to pass while we don't
|
||||
// properly support initializing imported C++ classes.
|
||||
|
||||
Reference in New Issue
Block a user