[clang] [Clang] Add detailed notes explaining why is_aggregate evaluates to false (PR #152488)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 15 02:00:26 PDT 2025
================
@@ -2595,6 +2597,97 @@ 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;
+ }
+
+ bool HasInherited = llvm::any_of(D->decls(), [](auto const *Sub) {
+ bool Result = false;
+ if (auto *UD = dyn_cast<UsingDecl>(Sub)) {
+ Result = llvm::any_of(UD->shadows(), [](auto const &I) {
+ return isa<ConstructorUsingShadowDecl>(I);
+ });
+ }
+ return isa<ConstructorUsingShadowDecl>(Sub) || Result;
+ });
+
+ if (HasInherited) {
+ SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
+ << diag::TraitNotSatisfiedReason::InheritedCtr;
+ }
----------------
cor3ntin wrote:
The loop above should be sufficient, right? Why do we check for inherited constructors twice?
https://github.com/llvm/llvm-project/pull/152488
More information about the cfe-commits
mailing list