[clang] 33e2161 - [clang] makes `__is_trivially_equality_comparable` available as a struct

Christopher Di Bella via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 19 10:16:57 PDT 2023


Author: Christopher Di Bella
Date: 2023-04-19T17:16:40Z
New Revision: 33e21610f9cd40e991b7cac107ba190678970f81

URL: https://github.com/llvm/llvm-project/commit/33e21610f9cd40e991b7cac107ba190678970f81
DIFF: https://github.com/llvm/llvm-project/commit/33e21610f9cd40e991b7cac107ba190678970f81.diff

LOG: [clang] makes `__is_trivially_equality_comparable` available as a struct

Since this was originally a name in library, it needs an escape hatch
for versions of Clang that are slightly out-of-sync with libc++.

Differential Revision: https://reviews.llvm.org/D148677

Added: 
    clang/test/SemaCXX/libcxx_is_trivially_equality_comparable_hack.cpp

Modified: 
    clang/lib/Parse/ParseDeclCXX.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 638cc7604066a..45b0a1a5f8669 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1622,6 +1622,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
           tok::kw___is_signed,
           tok::kw___is_standard_layout,
           tok::kw___is_trivial,
+          tok::kw___is_trivially_equality_comparable,
           tok::kw___is_trivially_assignable,
           tok::kw___is_trivially_constructible,
           tok::kw___is_trivially_copyable,

diff  --git a/clang/test/SemaCXX/libcxx_is_trivially_equality_comparable_hack.cpp b/clang/test/SemaCXX/libcxx_is_trivially_equality_comparable_hack.cpp
new file mode 100644
index 0000000000000..b236ce09b2970
--- /dev/null
+++ b/clang/test/SemaCXX/libcxx_is_trivially_equality_comparable_hack.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++20 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++2b -fms-extensions -Wno-microsoft %s
+
+template <class T, class U>
+struct Same {
+  static constexpr auto value = __is_same(T, U);
+};
+
+template <class T>
+struct __is_trivially_equality_comparable { // expected-warning{{keyword '__is_trivially_equality_comparable' will be made available as an identifier for the remainder of the translation unit}}
+  using type = T;
+};
+
+using A = Same<__is_trivially_equality_comparable<int>::type, __is_trivially_equality_comparable<int>::type>;


        


More information about the cfe-commits mailing list