1616#include " clang/Basic/DiagnosticIDs.h"
1717#include " clang/Basic/DiagnosticParse.h"
1818#include " clang/Basic/DiagnosticSema.h"
19+ #include " clang/Basic/Specifiers.h"
1920#include " clang/Basic/TypeTraits.h"
2021#include " clang/Sema/EnterExpressionEvaluationContext.h"
2122#include " clang/Sema/Initialization.h"
@@ -2608,30 +2609,21 @@ static void DiagnoseNonAggregateReason(Sema &SemaRef, SourceLocation Loc,
26082609 << diag::TraitNotSatisfiedReason::InheritedCtr;
26092610 }
26102611
2611- bool HasInherited = llvm::any_of (D->decls (), [](auto const *Sub) {
2612- bool Result = false ;
2613- if (auto *UD = dyn_cast<UsingDecl>(Sub)) {
2614- Result = llvm::any_of (UD->shadows (), [](auto const &I) {
2615- return isa<ConstructorUsingShadowDecl>(I);
2616- });
2617- }
2618- return isa<ConstructorUsingShadowDecl>(Sub) || Result;
2619- });
2620-
2621- if (HasInherited) {
2612+ if (llvm::any_of (D->decls (), [](auto const *Sub) {
2613+ return isa<ConstructorUsingShadowDecl>(Sub);
2614+ })) {
26222615 SemaRef.Diag (Loc, diag::note_unsatisfied_trait_reason)
26232616 << diag::TraitNotSatisfiedReason::InheritedCtr;
26242617 }
26252618
26262619 for (const FieldDecl *Field : D->fields ()) {
2627- switch (Field->getAccess ()) {
2620+ auto AccessSpecifier = Field->getAccess ();
2621+ switch (AccessSpecifier) {
26282622 case AS_private:
2629- SemaRef.Diag (Loc, diag::note_unsatisfied_trait_reason)
2630- << diag::TraitNotSatisfiedReason::PrivateDirectDataMember;
2631- break ;
26322623 case AS_protected:
26332624 SemaRef.Diag (Loc, diag::note_unsatisfied_trait_reason)
2634- << diag::TraitNotSatisfiedReason::ProtectedDirectDataMember;
2625+ << diag::TraitNotSatisfiedReason::PrivateProtectedDirectDataMember
2626+ << (AccessSpecifier == AS_protected);
26352627 break ;
26362628 default :
26372629 break ;
@@ -2645,14 +2637,13 @@ static void DiagnoseNonAggregateReason(Sema &SemaRef, SourceLocation Loc,
26452637 << B.getSourceRange ();
26462638 continue ;
26472639 }
2648- switch (B.getAccessSpecifier ()) {
2640+ auto AccessSpecifier = B.getAccessSpecifier ();
2641+ switch (AccessSpecifier) {
26492642 case AS_private:
2650- SemaRef.Diag (Loc, diag::note_unsatisfied_trait_reason)
2651- << diag::TraitNotSatisfiedReason::PrivateDirectBase;
2652- break ;
26532643 case AS_protected:
26542644 SemaRef.Diag (Loc, diag::note_unsatisfied_trait_reason)
2655- << diag::TraitNotSatisfiedReason::ProtectedDirectBase;
2645+ << diag::TraitNotSatisfiedReason::PrivateProtectedDirectBase
2646+ << (AccessSpecifier == AS_protected);
26562647 break ;
26572648 default :
26582649 break ;
0 commit comments