[libcxx-commits] [libcxx] cac9a6f - [libc++] Remove noexcept specifier from operator""s

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 2 12:37:40 PDT 2022


Author: Nikolas Klauser
Date: 2022-09-02T21:37:32+02:00
New Revision: cac9a6fb0ea24665b6feb611fdff7fb28060e84a

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

LOG: [libc++] Remove noexcept specifier from operator""s

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

Reviewed By: ldionne, huixie90, #libc

Spies: libcxx-commits

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

Added: 
    libcxx/test/std/strings/basic.string.literals/noexcept.compile.pass.cpp

Modified: 
    libcxx/include/string

Removed: 
    


################################################################################
diff  --git a/libcxx/include/string b/libcxx/include/string
index 1ee0cdc51d5f7..89811716d3a2c 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -4736,7 +4736,7 @@ inline namespace literals
 
 #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);
     }

diff  --git a/libcxx/test/std/strings/basic.string.literals/noexcept.compile.pass.cpp b/libcxx/test/std/strings/basic.string.literals/noexcept.compile.pass.cpp
new file mode 100644
index 0000000000000..7f040e58269a3
--- /dev/null
+++ b/libcxx/test/std/strings/basic.string.literals/noexcept.compile.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+#include "test_macros.h"
+
+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


        


More information about the libcxx-commits mailing list