diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -2672,6 +2672,9 @@ }) && llvm::all_of(Decl->fields(), [](const FieldDecl *FD) { auto Type = FD->getType(); + if (Type->isArrayType()) + Type = Type->getBaseElementTypeUnsafe()->getCanonicalTypeUnqualified(); + if (Type->isReferenceType() || Type->isEnumeralType()) return false; if (const auto *RD = Type->getAsCXXRecordDecl()) diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp --- a/clang/test/SemaCXX/type-traits.cpp +++ b/clang/test/SemaCXX/type-traits.cpp @@ -3141,6 +3141,13 @@ }; static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsArray)); +struct TriviallyEqualityComparableContainsMultiDimensionArray { + int a[4][4]; + + bool operator==(const TriviallyEqualityComparableContainsMultiDimensionArray&) const = default; +}; +static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsMultiDimensionArray)); + struct TriviallyEqualityComparableNonTriviallyCopyable { TriviallyEqualityComparableNonTriviallyCopyable(const TriviallyEqualityComparableNonTriviallyCopyable&); ~TriviallyEqualityComparableNonTriviallyCopyable(); @@ -3292,6 +3299,20 @@ }; static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasEnum)); +struct NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs { + E e[1]; + + bool operator==(const NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs&) const = default; +}; +static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs)); + +struct NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs2 { + E e[1][1]; + + bool operator==(const NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs2&) const = default; +}; +static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs2)); + namespace hidden_friend { struct TriviallyEqualityComparable {