diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp --- a/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp +++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp @@ -13,14 +13,16 @@ // explicit basic_fstream(const wchar_t* s, ios_base::openmode mode = ios_base::in | ios_base::out); +// This extension is only provided on Windows. +// REQUIRES: windows +// UNSUPPORTED: no-wide-characters + #include #include #include "test_macros.h" -#include "platform_support.h" +#include "wide_temp_file.h" -int main(int, char**) -{ -#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +int main(int, char**) { std::wstring temp = get_wide_temp_file_name(); { std::fstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out @@ -42,7 +44,6 @@ assert(x == 3.25); } _wremove(temp.c_str()); -#endif - return 0; + return 0; } diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp --- a/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp +++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp @@ -13,14 +13,16 @@ // void open(const wchar_t* s, ios_base::openmode mode = ios_base::in|ios_base::out); +// This extension is only provided on Windows. +// REQUIRES: windows +// UNSUPPORTED: no-wide-characters + #include #include #include "test_macros.h" -#include "platform_support.h" +#include "wide_temp_file.h" -int main(int, char**) -{ -#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +int main(int, char**) { std::wstring temp = get_wide_temp_file_name(); { std::fstream fs; @@ -48,7 +50,6 @@ assert(x == 3.25); } _wremove(temp.c_str()); -#endif - return 0; + return 0; } diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp --- a/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp +++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp @@ -13,6 +13,10 @@ // explicit basic_ifstream(const wchar_t* s, ios_base::openmode mode = ios_base::in); +// This extension is only provided on Windows. +// REQUIRES: windows +// UNSUPPORTED: no-wide-characters + // FILE_DEPENDENCIES: test.dat #include @@ -20,9 +24,7 @@ #include "test_macros.h" -int main(int, char**) -{ -#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +int main(int, char**) { { std::ifstream fs(L"test.dat"); double x = 0; @@ -41,7 +43,6 @@ // std::wifstream(const wchar_t*, std::ios_base::openmode) is tested in // test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp // which creates writable files. -#endif - return 0; + return 0; } diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp --- a/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp +++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp @@ -13,6 +13,10 @@ // void open(const wchar_t* s, ios_base::openmode mode = ios_base::in); +// This extension is only provided on Windows. +// REQUIRES: windows +// UNSUPPORTED: no-wide-characters + // FILE_DEPENDENCIES: test.dat #include @@ -20,9 +24,7 @@ #include "test_macros.h" -int main(int, char**) -{ -#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +int main(int, char**) { { std::ifstream fs; assert(!fs.is_open()); @@ -47,7 +49,6 @@ fs >> c; assert(c == L'r'); } -#endif - return 0; + return 0; } diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp --- a/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp +++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp @@ -13,14 +13,16 @@ // explicit basic_ofstream(const wchar_t* s, ios_base::openmode mode = ios_base::out); +// This extension is only provided on Windows. +// REQUIRES: windows +// UNSUPPORTED: no-wide-characters + #include #include #include "test_macros.h" -#include "platform_support.h" +#include "wide_temp_file.h" -int main(int, char**) -{ -#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +int main(int, char**) { std::wstring temp = get_wide_temp_file_name(); { std::ofstream fs(temp.c_str()); @@ -56,7 +58,6 @@ assert(x == 3.25); } _wremove(temp.c_str()); -#endif - return 0; + return 0; } diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp --- a/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp +++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp @@ -13,14 +13,16 @@ // void open(const wchar_t* s, ios_base::openmode mode = ios_base::out); +// This extension is only provided on Windows. +// REQUIRES: windows +// UNSUPPORTED: no-wide-characters + #include #include #include "test_macros.h" -#include "platform_support.h" +#include "wide_temp_file.h" -int main(int, char**) -{ -#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +int main(int, char**) { std::wstring temp = get_wide_temp_file_name(); { std::ofstream fs; @@ -56,7 +58,6 @@ assert(c == L'a'); } _wremove(temp.c_str()); -#endif - return 0; + return 0; } diff --git a/libcxx/test/support/platform_support.h b/libcxx/test/support/platform_support.h --- a/libcxx/test/support/platform_support.h +++ b/libcxx/test/support/platform_support.h @@ -35,8 +35,6 @@ #include #include -#include -#include #include #if defined(_WIN32) # include // _mktemp_s @@ -85,17 +83,6 @@ #endif } -_LIBCPP_SUPPRESS_DEPRECATED_PUSH -#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR -inline -std::wstring get_wide_temp_file_name() -{ - return std::wstring_convert >().from_bytes( - get_temp_file_name()); -} -#endif // _LIBCPP_HAS_OPEN_WITH_WCHAR -_LIBCPP_SUPPRESS_DEPRECATED_POP - #if defined(_CS_GNU_LIBC_VERSION) inline bool glibc_version_less_than(char const* version) { std::string test_version = std::string("glibc ") + version; diff --git a/libcxx/test/support/wide_temp_file.h b/libcxx/test/support/wide_temp_file.h new file mode 100644 --- /dev/null +++ b/libcxx/test/support/wide_temp_file.h @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_SUPPORT_WIDE_TEMP_FILE_H +#define TEST_SUPPORT_WIDE_TEMP_FILE_H + +#include +#include +#include + +#include "platform_support.h" +#include "test_macros.h" + +TEST_DIAGNOSTIC_PUSH +TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") +TEST_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") +inline std::wstring get_wide_temp_file_name() { + return std::wstring_convert >().from_bytes(get_temp_file_name()); +} +TEST_DIAGNOSTIC_POP + +#endif // TEST_SUPPORT_WIDE_TEMP_FILE_H diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -236,7 +236,7 @@ when=lambda cfg, alts=alts: hasAnyLocale(cfg, alts))) -# Add features representing the platform name: darwin, linux, windows, etc... +# Add features representing the target platform name: darwin, linux, windows, etc... DEFAULT_FEATURES += [ Feature(name='darwin', when=lambda cfg: '__APPLE__' in compilerMacros(cfg)), Feature(name='windows', when=lambda cfg: '_WIN32' in compilerMacros(cfg)),