diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 56447b56e8db1..cf63876cb08d3 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -13558,9 +13558,14 @@ bool ASTContext::containsCapabilities(const RecordDecl *RD) const { const QualType Ty = i->getType(); if (Ty->isCHERICapabilityType(*this)) return true; - if (const RecordType *RT = Ty->getAs()) + if (const RecordType *RT = Ty->getAs()) { + if (RT->isIncompleteType()) + // This can only occur when an error has occurred earlier, so it + // isn't too important what we return. + return false; if (containsCapabilities(RT->getDecl())) return true; + } if (Ty->isArrayType() && containsCapabilities(Ty)) return true; }