[clang] [Clang] Allow __is_nothrow_convertible to be used as an identifier (PR #80476)

Nikolas Klauser via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 2 11:07:41 PST 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/80476

`__is_nothrow_convertible` has been used by libstdc++ previously as an identifier.


>From fb4160b50535fd16951c5261e6c7d91da0cd92b0 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Fri, 2 Feb 2024 20:06:29 +0100
Subject: [PATCH] [Clang] Allow __is_nothrow_convertible to be used as an
 identifier

---
 clang/lib/Parse/ParseDeclCXX.cpp                   |  1 +
 .../libstdcxx_is_nothrow_convertible_hack.cpp      | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 clang/test/SemaCXX/libstdcxx_is_nothrow_convertible_hack.cpp

diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index cdbfbb1bc9fff..79928ddb5af59 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1725,6 +1725,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
           tok::kw___is_member_pointer,
           tok::kw___is_nothrow_assignable,
           tok::kw___is_nothrow_constructible,
+          tok::kw___is_nothrow_convertible,
           tok::kw___is_nothrow_destructible,
           tok::kw___is_nullptr,
           tok::kw___is_object,
diff --git a/clang/test/SemaCXX/libstdcxx_is_nothrow_convertible_hack.cpp b/clang/test/SemaCXX/libstdcxx_is_nothrow_convertible_hack.cpp
new file mode 100644
index 0000000000000..9e84f0ab1c081
--- /dev/null
+++ b/clang/test/SemaCXX/libstdcxx_is_nothrow_convertible_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++23 -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_nothrow_convertible { // expected-warning{{keyword '__is_nothrow_convertible' will be made available as an identifier for the remainder of the translation unit}}
+  using type = T;
+};
+
+using A = Same<__is_nothrow_convertible<int>::type, __is_nothrow_convertible<int>::type>;



More information about the cfe-commits mailing list