From cac9a6fb0ea24665b6feb611fdff7fb28060e84a Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Fri, 2 Sep 2022 16:20:28 +0200 Subject: [PATCH] [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 --- libcxx/include/string | 2 +- .../noexcept.compile.pass.cpp | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 libcxx/test/std/strings/basic.string.literals/noexcept.compile.pass.cpp diff --git a/libcxx/include/string b/libcxx/include/string index 1ee0cdc..8981171 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 operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT + basic_string operator "" s(const char8_t *__str, size_t __len) { return basic_string (__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 0000000..7f040e5 --- /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 + +#include "test_macros.h" + +static_assert(!noexcept(std::operator""s(std::declval(), std::declval())), ""); +#ifndef TEST_HAS_NO_CHAR8_T +static_assert(!noexcept(std::operator""s(std::declval(), std::declval())), ""); +#endif +static_assert(!noexcept(std::operator""s(std::declval(), std::declval())), ""); +static_assert(!noexcept(std::operator""s(std::declval(), std::declval())), ""); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!noexcept(std::operator""s(std::declval(), std::declval())), ""); +#endif -- 2.7.4