[libcxx-commits] [PATCH] D132340: [libc++] Remove noexcept specifier from operator""s

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Aug 21 18:18:40 PDT 2022


philnik created this revision.
philnik added reviewers: Mordante, var-const, ldionne, huixie90.
Herald added a project: All.
philnik requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

For some reason `operator""s(const char8_t*, size_t)` was marked `noexcept`. Remove it and add regression tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132340

Files:
  libcxx/include/string
  libcxx/test/std/strings/basic.string.literals/noexcept.compile.pass.cpp
  libcxx/test/std/strings/string.classes/typedefs.compile.pass.cpp


Index: libcxx/test/std/strings/string.classes/typedefs.compile.pass.cpp
===================================================================
--- libcxx/test/std/strings/string.classes/typedefs.compile.pass.cpp
+++ libcxx/test/std/strings/string.classes/typedefs.compile.pass.cpp
@@ -26,7 +26,7 @@
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
 static_assert((std::is_same<std::wstring, std::basic_string<wchar_t> >::value), "");
 #endif
-#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
+#ifndef TEST_HAS_NO_CHAR8_T
 static_assert((std::is_same<std::u8string, std::basic_string<char8_t> >::value), "");
 #endif
 static_assert((std::is_same<std::u16string, std::basic_string<char16_t> >::value), "");
Index: libcxx/test/std/strings/basic.string.literals/noexcept.compile.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/std/strings/basic.string.literals/noexcept.compile.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11
+
+#include <string>
+
+static_assert(!noexcept(std::operator""s(std::declval<const char*>(), std::declval<int>())));
+#ifndef TEST_HAS_NO_CHAR8_T
+static_assert(!noexcept(std::operator""s(std::declval<const char8_t*>(), std::declval<int>())));
+#endif
+static_assert(!noexcept(std::operator""s(std::declval<const char16_t*>(), std::declval<int>())));
+static_assert(!noexcept(std::operator""s(std::declval<const char32_t*>(), std::declval<int>())));
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!noexcept(std::operator""s(std::declval<const wchar_t*>(), std::declval<int>())));
+#endif
Index: libcxx/include/string
===================================================================
--- libcxx/include/string
+++ libcxx/include/string
@@ -4736,7 +4736,7 @@
 
 #ifndef _LIBCPP_HAS_NO_CHAR8_T
     inline _LIBCPP_HIDE_FROM_ABI constexpr
-    basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT
+    basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len)
     {
         return basic_string<char8_t> (__str, __len);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132340.454352.patch
Type: text/x-patch
Size: 2441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220822/deff4ad7/attachment.bin>


More information about the libcxx-commits mailing list