================ @@ -2639,6 +2642,87 @@ static void DiagnoseNonStandardLayoutReason(Sema &SemaRef, SourceLocation Loc, SemaRef.Diag(D->getLocation(), diag::note_defined_here) << D; } +static void DiagnoseNonAggregateReason(Sema &SemaRef, SourceLocation Loc, + const CXXRecordDecl *D) { + for (const CXXConstructorDecl *Ctor : D->ctors()) { + if (Ctor->isUserProvided()) + SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason) + << diag::TraitNotSatisfiedReason::UserDeclaredCtr; + if (Ctor->isInheritingConstructor()) + SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason) + << diag::TraitNotSatisfiedReason::InheritedCtr; + } + + if (llvm::any_of(D->decls(), [](auto const *Sub) { + return isa<ConstructorUsingShadowDecl>(Sub); + })) { + SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason) + << diag::TraitNotSatisfiedReason::InheritedCtr; + } + + for (const FieldDecl *Field : D->fields()) { + auto AccessSpecifier = Field->getAccess(); + switch (AccessSpecifier) { + case AS_private: + case AS_protected: + SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason) + << diag::TraitNotSatisfiedReason::PrivateProtectedDirectDataMember + << (AccessSpecifier == AS_protected); + break; + default: + break; + } + } + + for (const CXXBaseSpecifier &B : D->bases()) { ---------------- ojhunt wrote:
This is kind of a nit: I feel like base classes should go prior to fields. As an actual issue you may need to diagnose bases recursively as the reason for a type being a non-aggregate may not be direct. e.g. I'm not sure what diagnostic would be produced here for something like ```cpp class A {}; class B: private A {}; class C: public B {}; require is_aggregate(C) ``` https://github.com/llvm/llvm-project/pull/152488 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits