Skip to content

Commit 8d1ce5f

Browse files
committed
Added polymorphic check.
1 parent c107f67 commit 8d1ce5f

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,7 @@ def note_unsatisfied_trait_reason
17951795
"%NTCBase{has a non-trivially-copyable base %1}|"
17961796
"%NTCField{has a non-trivially-copyable member %1 of type %2}|"
17971797
"%NonEmptyMember{has a non-static data member %1 of type %2}|"
1798+
"%PolymorphicType{is a polymorphic type}|"
17981799
"%VirtualFunction{has a virtual function %1}|"
17991800
"%NonEmptyBase{has a base class %1 that is not empty}|"
18001801
"%NonZeroLengthField{field %1 is a non-zero-length bit-field}|"

clang/lib/Sema/SemaTypeTraits.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,6 +2694,11 @@ static void DiagnoseNonAggregateReason(Sema &SemaRef, SourceLocation Loc,
26942694
}
26952695
}
26962696

2697+
if (D->isPolymorphic())
2698+
SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
2699+
<< diag::TraitNotSatisfiedReason::PolymorphicType
2700+
<< D->getSourceRange();
2701+
26972702
for (const CXXMethodDecl *Method : D->methods()) {
26982703
if (Method->isVirtual()) {
26992704
SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)

clang/test/SemaCXX/type-traits-unsatisfied-diags.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ namespace is_aggregate {
959959
// expected-note@-1 {{because it has a virtual function 'foo'}} \
960960
// expected-note@-1 {{because it has a virtual base}} \
961961
// expected-note@-1 {{'S7' is not aggregate}} \
962+
// expected-note@-1 {{because it is a polymorphic type}} \
962963
// expected-note@#ag-S7 {{'S7' defined here}}
963964

964965
static_assert(__is_aggregate(S7[10]));

0 commit comments

Comments
 (0)