[clang] [Clang] Add diagnostic for why std::is_abstract is false (PR #156199)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 22 17:53:29 PDT 2025
================
@@ -2774,6 +2775,66 @@ static void DiagnoseNonAggregateReason(Sema &SemaRef, SourceLocation Loc,
DiagnoseNonAggregateReason(SemaRef, Loc, D);
}
+static void DiagnoseNonAbstractReason(Sema &SemaRef, SourceLocation Loc,
+ const CXXRecordDecl *D) {
+ // If this type has any abstract base classes, their respective virtual
+ // functions must have been overridden.
+ for (const CXXBaseSpecifier &B : D->bases()) {
+ assert(B.getType()->getAsCXXRecordDecl() && "invalid base?");
+ if (B.getType()->getAsCXXRecordDecl()->isAbstract()) {
+ SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
+ << diag::TraitNotSatisfiedReason::OverridesAllPureVirtual
+ << B.getType() << B.getSourceRange();
+ }
+ }
+}
+
+static void DiagnoseNonAbstractReason(Sema &SemaRef, SourceLocation Loc,
+ QualType T) {
+ SemaRef.Diag(Loc, diag::note_unsatisfied_trait)
+ << T << diag::TraitName::Abstract;
+
+ if (T->isReferenceType()) {
+ SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
+ << diag::TraitNotSatisfiedReason::Ref;
+ SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
+ << diag::TraitNotSatisfiedReason::NotStructOrClass;
+ return;
+ }
+
+ if (T->isUnionType()) {
----------------
shafik wrote:
This case does not look covered in the tests. Always make sure you cover all the diagnostics and various branches.
https://github.com/llvm/llvm-project/pull/156199
More information about the cfe-commits
mailing list