From 5fd17ab1b093f6b59aabb27f6c2c2278e65c2707 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 10 Feb 2016 00:59:02 +0000 Subject: Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from and wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr from to provide a const-correct overload set even when the underlying C library does not. This change adds a new macro, _LIBCPP_PREFERRED_OVERLOAD, which (if defined) specifies that a given overload is a better match than an otherwise equally good function declaration without the overload. This is implemented in modern versions of Clang via __attribute__((enable_if)), and not elsewhere. We use this new macro to define overloads in the global namespace for these functions that displace the overloads provided by the C library, unless we believe the C library is already providing the correct signatures. llvm-svn: 260337 --- libcxx/test/std/strings/c.strings/cstring.pass.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'libcxx/test/std/strings/c.strings/cstring.pass.cpp') diff --git a/libcxx/test/std/strings/c.strings/cstring.pass.cpp b/libcxx/test/std/strings/c.strings/cstring.pass.cpp index 20f4050cfbd..63f86d35061 100644 --- a/libcxx/test/std/strings/c.strings/cstring.pass.cpp +++ b/libcxx/test/std/strings/c.strings/cstring.pass.cpp @@ -34,17 +34,12 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); -// static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); -// static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); -// static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); -// static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); -// static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS static_assert((std::is_same::value), ""); @@ -52,4 +47,15 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + + // These tests fail on systems whose C library doesn't provide a correct overload + // set for strchr, strpbrk, strrchr, strstr, and memchr, unless the compiler is + // a suitably recent version of Clang. +#if !defined(__APPLE__) || defined(_LIBCPP_PREFERRED_OVERLOAD) + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif } -- cgit v1.2.3