Skip to content

Commit d65412a

Browse files
committed
Fixed problems.
1 parent 51ad2f0 commit d65412a

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,10 +1819,8 @@ def note_unsatisfied_trait_reason
18191819
"%FunctionType{is a function type}|"
18201820
"%CVVoidType{is a cv void type}|"
18211821
"%IncompleteArrayType{is an incomplete array type}|"
1822-
"%PrivateDirectDataMember{has a private direct data member}|"
1823-
"%ProtectedDirectDataMember{has a protected direct data member}|"
1824-
"%PrivateDirectBase{has a private direct base}|"
1825-
"%ProtectedDirectBase{has a protected direct base}"
1822+
"%PrivateProtectedDirectDataMember{has a %select{private|protected}1 direct data member}|"
1823+
"%PrivateProtectedDirectBase{has a %select{private|protected}1 direct base}|"
18261824
"}0">;
18271825

18281826
def warn_consteval_if_always_true : Warning<

clang/lib/Sema/SemaTypeTraits.cpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
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

Comments
 (0)