Author: Nikolas Klauser Date: 2023-06-28T13:34:02-07:00 New Revision: 3cf8b982042e91d9aabb880ccc7a556256187ff9
URL: https://github.com/llvm/llvm-project/commit/3cf8b982042e91d9aabb880ccc7a556256187ff9 DIFF: https://github.com/llvm/llvm-project/commit/3cf8b982042e91d9aabb880ccc7a556256187ff9.diff LOG: [clang] Fix checking the equality comparator of base classes in __is_trivially_equality_comparable Fixes #63192 Reviewed By: cor3ntin Spies: cfe-commits Differential Revision: https://reviews.llvm.org/D153890 Added: Modified: clang/lib/AST/Type.cpp clang/test/SemaCXX/type-traits.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 646eba90973f5..7ffed145c5fe5 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -2667,7 +2667,7 @@ HasNonDeletedDefaultedEqualityComparison(const CXXRecordDecl *Decl) { return llvm::all_of(Decl->bases(), [](const CXXBaseSpecifier &BS) { if (const auto *RD = BS.getType()->getAsCXXRecordDecl()) - HasNonDeletedDefaultedEqualityComparison(RD); + return HasNonDeletedDefaultedEqualityComparison(RD); return true; }) && llvm::all_of(Decl->fields(), [](const FieldDecl *FD) { diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp index 9bb093e985cfc..ba52ca748fed7 100644 --- a/clang/test/SemaCXX/type-traits.cpp +++ b/clang/test/SemaCXX/type-traits.cpp @@ -3264,6 +3264,21 @@ struct NotTriviallyEqualityComparableHasReferenceMember { }; static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasReferenceMember)); +struct NotTriviallyEqualityComparableNonTriviallyComparableBaseBase { + int i; + + bool operator==(const NotTriviallyEqualityComparableNonTriviallyComparableBaseBase&) const { + return true; + } +}; + +struct NotTriviallyEqualityComparableNonTriviallyComparableBase : NotTriviallyEqualityComparableNonTriviallyComparableBaseBase { + int i; + + bool operator==(const NotTriviallyEqualityComparableNonTriviallyComparableBase&) const = default; +}; +static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyComparableBase)); + enum E { a, b _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits